|
def __init__( |
|
self, |
|
app: WSGIApplication, |
|
exports: ( |
|
dict[str, str | tuple[str, str]] |
|
| t.Iterable[tuple[str, str | tuple[str, str]]] |
|
), |
|
disallow: None = None, |
|
cache: bool = True, |
|
cache_timeout: int = 60 * 60 * 12, |
|
fallback_mimetype: str = "application/octet-stream", |
|
) -> None: |
exports is annotated as dict[str, str | tuple[str, str]] (plus the iterable case). Because dict is invariant, passing a simple dict[str, str] actually produces a mypy error! Users can work around this by manually annotating the data as dict[str, str | tuple[str, str]], but this is very unergonomic.
https://mypy-play.net/?mypy=latest&python=3.12&gist=7194ebea2b603890033453b8d735e232 is a minimal demonstration of this issue, and the recommended workaround: annotating the value as collections.Mapping instead.
werkzeug/src/werkzeug/middleware/shared_data.py
Lines 102 to 113 in 5add63c
exportsis annotated asdict[str, str | tuple[str, str]](plus the iterable case). Becausedictis invariant, passing a simpledict[str, str]actually produces a mypy error! Users can work around this by manually annotating the data asdict[str, str | tuple[str, str]], but this is very unergonomic.https://mypy-play.net/?mypy=latest&python=3.12&gist=7194ebea2b603890033453b8d735e232 is a minimal demonstration of this issue, and the recommended workaround: annotating the value as
collections.Mappinginstead.