[issue47166] Dataclass transform should ignore TypeAlias variables
New submission from Thomas MK : The dataclass transformation ignores attributes that are annotated as ClassVar. I think it should also ignore attributes that are annotated as TypeAlias. Specifically, I have this usecase in mind: class RunMode(Enum): release = auto() debug = auto() @dataclass class Run: Mode: TypeAlias = RunMode mode: Mode = Mode.release -- components: Library (Lib) messages: 416368 nosy: thomkeh priority: normal severity: normal status: open title: Dataclass transform should ignore TypeAlias variables type: behavior versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue47166> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue47166] Dataclass transform should ignore TypeAlias variables
Thomas MK added the comment: There is of course no hard reason for not using the global scope. I just often have enums (or other types) that are very closely linked to one class. And it makes sense to me then to have a TypeAlias in that class so that I don't have to import the enum separately. For normal classes, the nested TypeAlias works completely fine in the type checkers I tested (pyright and mypy). It's just dataclasses that are the problem. But I see now that there is a general wish to keep the implementation of dataclass simple, which I can understand. -- ___ Python tracker <https://bugs.python.org/issue47166> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com