File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 11from types import NotImplementedType
2- from typing import Any
2+ from typing import final
33
4+ from typing_extensions import override
45
6+
7+ @final
58class Nothing :
69 """Represents the absence of a value.
710
811 Rarely instantiated on its own, see :func:`Optional.empty`"""
912
10- def __eq__ (self , other : Any ) -> bool | NotImplementedType :
13+ @override
14+ def __eq__ (self , other : object ) -> bool | NotImplementedType :
1115 if not isinstance (other , Nothing ):
1216 return NotImplemented
1317
1418 return True
1519
20+ @override
1621 def __repr__ (self ) -> str :
1722 return "Optional.empty()"
1823
Original file line number Diff line number Diff line change 11from types import NotImplementedType
2- from typing import Any , Generic , TypeVar
2+ from typing import Generic , TypeVar , final
3+
4+ from typing_extensions import override
35
46T = TypeVar ("T" )
57
68
9+ @final
710class Something (Generic [T ]):
811 """Represents the presence of a value.
912
@@ -17,12 +20,14 @@ def __init__(self, value: T) -> None:
1720
1821 self ._value = value
1922
20- def __eq__ (self , other : Any ) -> bool | NotImplementedType :
23+ @override
24+ def __eq__ (self , other : object ) -> bool | NotImplementedType :
2125 if not isinstance (other , Something ):
2226 return NotImplemented
2327
2428 return self ._value == other ._value
2529
30+ @override
2631 def __repr__ (self ) -> str :
2732 return f"Optional.of({ self ._value !r} )"
2833
You can’t perform that action at this time.
0 commit comments