Treat TypedDict (old-style) aliases as regular TypedDicts#18852
Treat TypedDict (old-style) aliases as regular TypedDicts#18852hauntsaninja merged 4 commits intopython:masterfrom
TypedDict (old-style) aliases as regular TypedDicts#18852Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This is rather important - stdlib stubs use TypedDict aliases (e.g. |
|
Diff from mypy_primer, showing the effect of this PR on open source code: hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- src/hydra_zen/structured_configs/_implementations.py:2950: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "str" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2950: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "tuple[type, ...]" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2950: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "dict[str, Any] | None" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2950: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "bool" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2950: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "str | None" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3310: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "str" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3310: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "tuple[type, ...]" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3310: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "dict[str, Any] | None" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3310: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "bool" [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3310: error: Argument 2 to "make_dataclass" has incompatible type "**StrictDataclassOptions"; expected "str | None" [arg-type]
|
hauntsaninja
left a comment
There was a problem hiding this comment.
Worth adding a test case for the PEP 695 alias?
|
@hauntsaninja We should already have a hard error whenever PEP695 |
|
Was a question, sounds like your answer is no! Thanks for the fix! |
Fixes #18692.
This PR makes mypy recognize old-style aliases to TypedDict types:
Still doesn't support generic no_args aliases:
that's because
no_argsaliases are handled in code in several places and all of them expect such an alias to haveInstancetarget.