Skip to content

0.41.3 introduces a breaking change to add_middleware #2757

Answered by uriyyo
glung asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @glung,

I tried to reproduce this issue using latest mypy version 1.13.0 and starlette 0.41.3 and can't reproduce this issue.

Here is code that I used:

from starlette.applications import Starlette
from starlette.middleware.cors import CORSMiddleware

app = Starlette()

origins = [
    "http://localhost",
    "http://localhost:8080",
]

allow_origin_regex = r"https://.*\.example\.org"

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_origin_regex=allow_origin_regex,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
$ mypy foo.py --strict
Success: no issues found in 1 source file

Could you please provide more context?

Replies: 3 comments 1 reply

Comment options

Kludex
Nov 19, 2024
Maintainer Sponsor

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
1 reply
@adriangb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants