[issue45384] Accept Final as indicating ClassVar for dataclass
Mehdi2277
report at bugs.python.org
Thu Jan 20 20:21:16 EST 2022
Mehdi2277 <med2277 at gmail.com> added the comment:
I recently hit this issue working on a config/parsing runtime type checking library (similar in spirit to pydantic).
The one other special typeform I was using these with that led me to discover this issue was Annotated. I use Annotated a fair amount to do some runtime analysis and I was used to `Annotated[typeform]` always works. But ClassVar and Final are special and `Annotated[ClassVar[...]] `and `Annotated[Final[...]]` both fail. I find `Annotated` interaction also weird. I ended up working around it by doing `ClassVar[Annotated[...]]` and stripping the classvar/final to look for the annotation metadata.
I think all 3 of annotated/final/classvar should be order compatible as they all serve to add information on the type they contain.
If we ignore Annotated, I would say ClassVar/Final should be order compatible and a rule that Final[ClassVar[...]] works but not ClassVar[Final[...]] or vice versa would be weird.
----------
nosy: +med2277
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45384>
_______________________________________
More information about the Python-bugs-list
mailing list