Skip to content

Commit 7ab0f87

Browse files
committed
Satisfy some linter/LSP warnings
1 parent d706e09 commit 7ab0f87

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

optional/nothing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
from types import NotImplementedType
2-
from typing import Any
2+
from typing import Any, override
33

44

55
class Nothing:
66
"""Represents the absence of a value.
77
88
Rarely instantiated on its own, see :func:`Optional.empty`"""
99

10+
@override
1011
def __eq__(self, other: Any) -> bool | NotImplementedType:
1112
if not isinstance(other, Nothing):
1213
return NotImplemented
1314

1415
return True
1516

17+
@override
1618
def __repr__(self) -> str:
1719
return "Optional.empty()"
1820

optional/something.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from types import NotImplementedType
2-
from typing import Any, Generic, TypeVar
2+
from typing import Any, Generic, TypeVar, override
33

44
T = TypeVar("T")
55

@@ -17,12 +17,14 @@ def __init__(self, value: T) -> None:
1717

1818
self._value = value
1919

20+
@override
2021
def __eq__(self, other: Any) -> bool | NotImplementedType:
2122
if not isinstance(other, Something):
2223
return NotImplemented
2324

2425
return self._value == other._value
2526

27+
@override
2628
def __repr__(self) -> str:
2729
return f"Optional.of({self._value!r})"
2830

tests/test_optional.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55

66
def test_can_instantiate():
7-
Optional.of()
7+
_ = Optional.of()
88

99

1010
def test_can_instantiate_empty():
11-
Optional.empty()
11+
_ = Optional.empty()
1212

1313

1414
def test_can_instantiate_with_content():
15-
Optional.of("something")
15+
_ = Optional.of("something")
1616

1717

1818
def test_can_instantiate_with_none():
19-
Optional.of(None)
19+
_ = Optional.of(None)
2020

2121

2222
def test_can_structurally_match_against_nothing():

tests/test_something.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
def test_can_not_instantiate_with_a_none_value():
77
with pytest.raises(ValueError, match="\\AInvalid value for Something: None\\Z"):
8-
Something(None)
8+
_ = Something(None)
99

1010

1111
def test_can_instantiate_with_any_other_value():

0 commit comments

Comments
 (0)