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)
| 743 | |
| 744 | @_SpecialForm |
| 745 | def 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 |
| 767 | def Optional(self, parameters): |
nothing calls this directly
no test coverage detected
searching dependent graphs…