File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-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 , override
33
44
5+ @final
56class Nothing :
67 """Represents the absence of a value.
78
89 Rarely instantiated on its own, see :func:`Optional.empty`"""
910
10- def __eq__ (self , other : Any ) -> bool | NotImplementedType :
11+ @override
12+ def __eq__ (self , other : object ) -> bool | NotImplementedType :
1113 if not isinstance (other , Nothing ):
1214 return NotImplemented
1315
1416 return True
1517
18+ @override
1619 def __repr__ (self ) -> str :
1720 return "Optional.empty()"
1821
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 , override
33
44T = TypeVar ("T" )
55
66
7+ @final
78class Something (Generic [T ]):
89 """Represents the presence of a value.
910
@@ -17,12 +18,14 @@ def __init__(self, value: T) -> None:
1718
1819 self ._value = value
1920
20- def __eq__ (self , other : Any ) -> bool | NotImplementedType :
21+ @override
22+ def __eq__ (self , other : object ) -> bool | NotImplementedType :
2123 if not isinstance (other , Something ):
2224 return NotImplemented
2325
2426 return self ._value == other ._value
2527
28+ @override
2629 def __repr__ (self ) -> str :
2730 return f"Optional.of({ self ._value !r} )"
2831
You can’t perform that action at this time.
0 commit comments