mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Add experimental support for PEP 764 inline TypedDicts

Open brianschubert opened this issue 8 months ago • 5 comments

Refs #18748

I opted to put this behavior behind a new feature flag (instead of tying it to the existing InlineTypedDict flag), since that helps avoid issues with mixing the existing syntax and PEP-764 syntax. Suggestions about how to name the flag / how to best reconcile this with the existing InlineTypedDict flag would be welcome.

brianschubert avatar Apr 05 '25 20:04 brianschubert

cc @Viicos

brianschubert avatar Apr 05 '25 20:04 brianschubert

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
- steam/http.py:907: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: error: Legacy inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: note: Did you mean TypedDict[...]?

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/validators.py:630: error: Unused "type: ignore" comment  [unused-ignore]
+ pydantic/v1/annotated_types.py:49: error: Unused "type: ignore" comment  [unused-ignore]

github-actions[bot] avatar Apr 05 '25 21:04 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
- steam/http.py:907: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: error: Legacy inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: note: Did you mean TypedDict[...]?

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/validators.py:630: error: Unused "type: ignore" comment  [unused-ignore]
+ pydantic/v1/annotated_types.py:49: error: Unused "type: ignore" comment  [unused-ignore]

github-actions[bot] avatar Apr 07 '25 14:04 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
- steam/http.py:907: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: error: Legacy inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:907: note: Did you mean TypedDict[...]?

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/validators.py:630: error: Unused "type: ignore" comment  [unused-ignore]
+ pydantic/v1/annotated_types.py:49: error: Unused "type: ignore" comment  [unused-ignore]

github-actions[bot] avatar Apr 17 '25 14:04 github-actions[bot]

Diff from mypy_primer, showing the effect of this PR on open source code:

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/validators.py:630: error: Unused "type: ignore" comment  [unused-ignore]
+ pydantic/v1/annotated_types.py:49: error: Unused "type: ignore" comment  [unused-ignore]

steam.py (https://github.com/Gobot1234/steam.py)
- steam/http.py:910: error: Inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:910: error: Legacy inline TypedDict is experimental, must be enabled with --enable-incomplete-feature=InlineTypedDict  [misc]
+ steam/http.py:910: note: Did you mean TypedDict[...]?

github-actions[bot] avatar Jun 07 '25 16:06 github-actions[bot]