MCPcopy Index your code
hub / github.com/python/cpython / Final

Function Final

Lib/typing.py:745–764  ·  view source on GitHub ↗

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

(self, parameters)

Source from the content-addressed store, hash-verified

743
744@_SpecialForm
745def Final(self, parameters):
746 """Special typing construct to indicate final names to type checkers.
747
748 A final name cannot be re-assigned or overridden in a subclass.
749
750 For example::
751
752 MAX_SIZE: Final = 9000
753 MAX_SIZE += 1 # Error reported by type checker
754
755 class Connection:
756 TIMEOUT: Final[int] = 10
757
758 class FastConnector(Connection):
759 TIMEOUT = 1 # Error reported by type checker
760
761 There is no runtime checking of these properties.
762 """
763 item = _type_check(parameters, f'{self} accepts only single type.', allow_special_forms=True)
764 return _GenericAlias(self, (item,))
765
766@_SpecialForm
767def Optional(self, parameters):

Callers

nothing calls this directly

Calls 2

_type_checkFunction · 0.85
_GenericAliasClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…