You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dataclass_transform decorator not detected when using alias #19731
I came across this while trying to conditionally use typing.dataclass_transform or typing_extensions.dataclass_transforms depending on the Python version running the code.
If one defines an alias for dataclass_transform, using the alias as a decorator does not result in the expected result (mypy does not recognize the decorated class as if being decorated with dataclass_transform)
There are multiple hardcoded fullnames in mypy that do not support aliasing. The same applies to typing.no_type_check and typing.TypedDict, for example.
Activity
sterliakov commentedon Aug 27, 2025
There are multiple hardcoded fullnames in mypy that do not support aliasing. The same applies to
typing.no_type_checkandtyping.TypedDict, for example.https://mypy-play.net/?mypy=master&python=3.10&flags=strict&gist=e75986dae521c8386ff818e57e79ad40
Apparently
dataclasses.dataclasscan't be aliased either.alex commentedon Sep 1, 2025
Is this a fundamental limitation of mypy's design, or just an incidental limitation for how these APIs were implemented?
sterliakov commentedon Sep 1, 2025
It's an implementation issue AFAIC. Maybe I'll try to get it working this week, there are multiple tickets caused by this.
alex commentedon Sep 1, 2025
Thanks!