MCPcopy Index your code
hub / github.com/RustPython/RustPython / Final

Function Final

Lib/typing.py:722–741  ·  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

720
721@_SpecialForm
722def Final(self, parameters):
723 """Special typing construct to indicate final names to type checkers.
724
725 A final name cannot be re-assigned or overridden in a subclass.
726
727 For example::
728
729 MAX_SIZE: Final = 9000
730 MAX_SIZE += 1 # Error reported by type checker
731
732 class Connection:
733 TIMEOUT: Final[int] = 10
734
735 class FastConnector(Connection):
736 TIMEOUT = 1 # Error reported by type checker
737
738 There is no runtime checking of these properties.
739 """
740 item = _type_check(parameters, f'{self} accepts only single type.', allow_special_forms=True)
741 return _GenericAlias(self, (item,))
742
743@_SpecialForm
744def Optional(self, parameters):

Callers

nothing calls this directly

Calls 2

_type_checkFunction · 0.85
_GenericAliasClass · 0.85

Tested by

no test coverage detected