(copied from typing on advice since this affects runtime behavior) PEP 591 for Final states "Type checkers should infer a final attribute that is initialized in a class body as being a class variable. Variables should not be annotated with both ClassVar and Final."
ClassVar is used to indicate library behavior in dataclasses. Therefore, I propose accepting the Final attribute as an indicator of a ClassVar in dataclass class bodies in order to be better compatible with the Final PEP. One edge case that would need to be handled is when someone might explicitly mark a dataclass field Final: a: Final[int] = dataclasses.field(init=False, default=10) I've opened an issue as well and would greatly appreciate any feedback: https://bugs.python.org/issue45384 I appreciate your time, Gregory Beauregard _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/HS2UEMTQJYPHXOI6FPU523JMCCHHRNGH/ Code of Conduct: http://python.org/psf/codeofconduct/