Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 662 Bytes

File metadata and controls

29 lines (21 loc) · 662 Bytes

typing.final

Links

Notes

Adding the @final decorator to a class or class method indicates that the object cannot be overridden. You can't subclass that class and you can't override that method in a subclass.

You can add it to either a class or a method on a class.

Example from the docs:

class Base:
    @final
    def done(self) -> None:
        ...
class Sub(Base):
    def done(self) -> None:  # Error reported by type checker
        ...

@final
class Leaf:
    ...
class Other(Leaf):  # Error reported by type checker
    ...