[Python-Dev] PEP 591 discussion (final qualifier) happening at typing-sig@
On Mon, Apr 15, 2019 at 5:00 PM Michael Sullivan <sully at msully.net> wrote:
> I've submitted PEP 591 (Adding a final qualifier to typing) for discussion to typing-sig .
I'm not on typing-sig  so I'm replying here.
> Here's the abstract:
> 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
I've been meaning to start blocking subclassing at runtime (e.g. like
), so being able to express that to the typechecker seems like a
nice addition. I'm assuming though that the '@final' decorator doesn't
have any runtime effect, so I'd have to say it twice?
Or on 3.6+ with __init_subclass__, it's easy to define a @final
decorator that works at runtime, but I guess this would have to be a
This seems kinda awkward. Have you considered giving it a runtime
effect, or providing some way for users to combine these two things
together on their own?
Nathaniel J. Smith -- https://vorpus.org