Skip to content

Commit 2c47de2

Browse files
authored
Type all comparison/operators dunders (#4583)
1 parent 2e5958b commit 2c47de2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pkg_resources/__init__.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ def __iter__(self) -> Iterator[str]:
13121312
if self[key]:
13131313
yield key
13141314

1315-
def __iadd__(self, other: Distribution | Environment):
1315+
def __iadd__(self, other: Distribution | Environment) -> Self:
13161316
"""In-place addition of a distribution or environment"""
13171317
if isinstance(other, Distribution):
13181318
self.add(other)
@@ -1324,7 +1324,7 @@ def __iadd__(self, other: Distribution | Environment):
13241324
raise TypeError("Can't add %r to environment" % (other,))
13251325
return self
13261326

1327-
def __add__(self, other: Distribution | Environment):
1327+
def __add__(self, other: Distribution | Environment) -> Self:
13281328
"""Add an environment or distribution to an environment"""
13291329
new = self.__class__([], platform=None, python=None)
13301330
for env in self, other:
@@ -2371,7 +2371,7 @@ class NoDists:
23712371
[]
23722372
"""
23732373

2374-
def __bool__(self):
2374+
def __bool__(self) -> Literal[False]:
23752375
return False
23762376

23772377
def __call__(self, fullpath: object):
@@ -2970,28 +2970,28 @@ def hashcmp(self):
29702970
self.platform or '',
29712971
)
29722972

2973-
def __hash__(self):
2973+
def __hash__(self) -> int:
29742974
return hash(self.hashcmp)
29752975

2976-
def __lt__(self, other: Distribution):
2976+
def __lt__(self, other: Distribution) -> bool:
29772977
return self.hashcmp < other.hashcmp
29782978

2979-
def __le__(self, other: Distribution):
2979+
def __le__(self, other: Distribution) -> bool:
29802980
return self.hashcmp <= other.hashcmp
29812981

2982-
def __gt__(self, other: Distribution):
2982+
def __gt__(self, other: Distribution) -> bool:
29832983
return self.hashcmp > other.hashcmp
29842984

2985-
def __ge__(self, other: Distribution):
2985+
def __ge__(self, other: Distribution) -> bool:
29862986
return self.hashcmp >= other.hashcmp
29872987

2988-
def __eq__(self, other: object):
2988+
def __eq__(self, other: object) -> bool:
29892989
if not isinstance(other, self.__class__):
29902990
# It's not a Distribution, so they are not equal
29912991
return False
29922992
return self.hashcmp == other.hashcmp
29932993

2994-
def __ne__(self, other: object):
2994+
def __ne__(self, other: object) -> bool:
29952995
return not self == other
29962996

29972997
# These properties have to be lazy so that we don't have to load any
@@ -3488,10 +3488,10 @@ def __init__(self, requirement_string: str) -> None:
34883488
)
34893489
self.__hash = hash(self.hashCmp)
34903490

3491-
def __eq__(self, other: object):
3491+
def __eq__(self, other: object) -> bool:
34923492
return isinstance(other, Requirement) and self.hashCmp == other.hashCmp
34933493

3494-
def __ne__(self, other):
3494+
def __ne__(self, other: object) -> bool:
34953495
return not self == other
34963496

34973497
def __contains__(
@@ -3513,7 +3513,7 @@ def __contains__(
35133513
prereleases=True,
35143514
)
35153515

3516-
def __hash__(self):
3516+
def __hash__(self) -> int:
35173517
return self.__hash
35183518

35193519
def __repr__(self) -> str:

0 commit comments

Comments
 (0)