Thanks for the write-up Sully. Two quick questions: 1. what’s the rationale for prohibiting `Final` in loops? I have a hunch this has to do with Python leaking scopes but not entirely sure. IIRC this is fine in Java. 2.
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.
I’m probably missing something here but why not support something like `attribute: ClassVar[Final[int]]`? Isn’t this conflating two unrelated concepts? ________________________________ From: Michael Sullivan <sully@msully.net> Sent: Monday, April 15, 2019 4:55 PM To: typing-sig@python.org Subject: [Typing-sig] PEP 591 discussion: final I've submitted PEP 591 to the PEPs repository. This PEP proposes a "final" qualifier to be added to the ``typing`` module---in the form of a ``final`` decorator and a ``Final`` type annotation---to serve three related purposes: * Declaring that a method should not be overridden * Declaring that a class should not be subclassed * Declaring that a variable or attribute should not be reassigned Discussion on the PEP happens here in typing-sig@. Minor things can be fixed directly as PRs. Here is the full PEP draft: https://www.python.org/dev/peps/pep-0591/ A reference implementation exists in mypy, whose documentation is here: https://mypy.readthedocs.io/en/stable/final_attrs.html (though the PEP takes precedence) -sully