Message 403890 - Python tracker

Message403890

Author msully4321
Recipients GBeauregard, carljm, eric.smith, msully4321, saaketp
Date 2021-10-14.07:55:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634198121.37.0.164288967409.issue45384@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-10-14 07:55:21msully4321setrecipients: + msully4321, eric.smith, carljm, GBeauregard, saaketp
2021-10-14 07:55:21msully4321setmessageid: <1634198121.37.0.164288967409.issue45384@roundup.psfhosted.org>
2021-10-14 07:55:21msully4321linkissue45384 messages
2021-10-14 07:55:21msully4321create