Michael Sullivan <msully4...@gmail.com> added the comment:
I tend to agree with Carl that making Final imply ClassVar for dataclass would make things worse. For better or worse (mostly better, but there are downsides like this!), dataclass class bodies are essentially written in their own domain specific language, and allowances need to be made in how typing things are interpreted in such a case, and I think that Carl is right that the right interpretation in the case of dataclasses is that the annotation describes the eventual instance attribute. At least, I feel this way 80% of the time. I can definitely see the argument for wanting consistency in the interpretation. >From a more directly practical perspective, though, the change would also be a >breaking one (though /arguably/ only of broken code), and so maybe not worth >it even if we would prefer the changed behavior. I think the right approach is probably to just append the PEP and then maybe also support ClassVar[Final[Whatever]]. It shouldn't need intersection types or anything; if it's a pain to implement it would be for annoying reasons and not deep ones. ---------- nosy: +msully4321 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45384> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com