PyDocs

Nav

Development Tools

Final

typing

data · Added in 3.8
Special typing construct to indicate final names to type checkers.

A final name cannot be re-assigned or overridden in a subclass.

For example::

    MAX_SIZE: Final = 9000
    MAX_SIZE += 1  # Error reported by type checker

    class Connection:
        TIMEOUT: Final[int] = 10

    class FastConnector(Connection):
        TIMEOUT = 1  # Error reported by type checker

There is no runtime checking of these properties.
Changed in 3.13
  • 3.13: Final can now be nested in ClassVar and vice versa.
0 Examples
No examples for typing/Final.
See Also
No see-alsos for typing/Final
0 Notes
No notes for Final