Skip to content

Commit 5c24b6d

Browse files
author
MomIsBestFriend
committed
Annotations to __eq__ function
1 parent 68115de commit 5c24b6d

File tree

14 files changed

+20
-29
lines changed

14 files changed

+20
-29
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import cython
22

33
import time
4-
from typing import Any
54
from cpython.datetime cimport (PyDateTime_IMPORT,
65
PyDateTime_Check,
76
PyDelta_Check,
@@ -329,7 +328,7 @@ class _BaseOffset:
329328
def __setattr__(self, name, value):
330329
raise AttributeError("DateOffset objects are immutable.")
331330

332-
def __eq__(self, other: Any) -> bool:
331+
def __eq__(self, other) -> bool:
333332
if isinstance(other, str):
334333
try:
335334
# GH#23524 if to_offset fails, we are dealing with an

pandas/core/arrays/sparse/dtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __hash__(self):
9090
# __eq__, so we explicitly do it here.
9191
return super().__hash__()
9292

93-
def __eq__(self, other: Any) -> bool:
93+
def __eq__(self, other) -> bool:
9494
# We have to override __eq__ to handle NA values in _metadata.
9595
# The base class does simple == checks, which fail for NA.
9696
if isinstance(other, str):

pandas/core/dtypes/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Extend pandas with custom array types"""
2-
from typing import Any, List, Optional, Tuple, Type
2+
from typing import List, Optional, Tuple, Type
33

44
import numpy as np
55

@@ -86,7 +86,7 @@ def __from_arrow__(
8686
def __str__(self) -> str:
8787
return self.name
8888

89-
def __eq__(self, other: Any) -> bool:
89+
def __eq__(self, other) -> bool:
9090
"""
9191
Check whether 'other' is equal to self.
9292

pandas/core/dtypes/dtypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def __hash__(self) -> int:
370370
# We *do* want to include the real self.ordered here
371371
return int(self._hash_categories(self.categories, self._ordered))
372372

373-
def __eq__(self, other: Any) -> bool:
373+
def __eq__(self, other) -> bool:
374374
"""
375375
Rules for CDT equality:
376376
1) Any CDT is equal to the string 'category'
@@ -765,7 +765,7 @@ def __hash__(self) -> int:
765765
# TODO: update this.
766766
return hash(str(self))
767767

768-
def __eq__(self, other: Any) -> bool:
768+
def __eq__(self, other) -> bool:
769769
if isinstance(other, str):
770770
return other == self.name
771771

@@ -904,7 +904,7 @@ def __hash__(self) -> int:
904904
# make myself hashable
905905
return hash(str(self))
906906

907-
def __eq__(self, other: Any) -> bool:
907+
def __eq__(self, other) -> bool:
908908
if isinstance(other, str):
909909
return other == self.name or other == self.name.title()
910910

@@ -1077,7 +1077,7 @@ def __hash__(self) -> int:
10771077
# make myself hashable
10781078
return hash(str(self))
10791079

1080-
def __eq__(self, other: Any) -> bool:
1080+
def __eq__(self, other) -> bool:
10811081
if isinstance(other, str):
10821082
return other.lower() in (self.name.lower(), str(self).lower())
10831083
elif not isinstance(other, IntervalDtype):

pandas/core/indexes/frozen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
- .levels & .codes (FrozenNDArray)
88
99
"""
10-
from typing import Any
1110
import warnings
1211

1312
import numpy as np
@@ -78,7 +77,7 @@ def __radd__(self, other):
7877
other = list(other)
7978
return self.__class__(other + list(self))
8079

81-
def __eq__(self, other: Any) -> bool:
80+
def __eq__(self, other) -> bool:
8281
if isinstance(other, (tuple, FrozenList)):
8382
other = list(other)
8483
return super().__eq__(other)

pandas/io/pytables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ def __repr__(self) -> str:
17641764
)
17651765
)
17661766

1767-
def __eq__(self, other: Any) -> bool:
1767+
def __eq__(self, other) -> bool:
17681768
""" compare 2 col items """
17691769
return all(
17701770
getattr(self, a, None) == getattr(other, a, None)
@@ -2092,7 +2092,7 @@ def __repr__(self) -> str:
20922092
)
20932093
)
20942094

2095-
def __eq__(self, other: Any) -> bool:
2095+
def __eq__(self, other) -> bool:
20962096
""" compare 2 col items """
20972097
return all(
20982098
getattr(self, a, None) == getattr(other, a, None)

pandas/io/stata.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os
1717
import struct
1818
import sys
19-
from typing import Any
2019
import warnings
2120

2221
from dateutil.relativedelta import relativedelta
@@ -860,7 +859,7 @@ def __repr__(self) -> str:
860859
# not perfect :-/
861860
return "{cls}({obj})".format(cls=self.__class__, obj=self)
862861

863-
def __eq__(self, other: Any) -> bool:
862+
def __eq__(self, other) -> bool:
864863
return (
865864
isinstance(other, self.__class__)
866865
and self.string == other.string

pandas/tests/groupby/test_function.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from io import StringIO
44
from itertools import product
55
from string import ascii_lowercase
6-
from typing import Any
76

87
import numpy as np
98
import pytest
@@ -1231,7 +1230,7 @@ def __init__(self, msg="I will raise inside Cython"):
12311230
super().__init__()
12321231
self.msg = msg
12331232

1234-
def __eq__(self, other: Any):
1233+
def __eq__(self, other):
12351234
# gets called in Cython to check that raising calls the method
12361235
raise RaisingObjectException(self.msg)
12371236

pandas/tests/indexing/test_indexing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from datetime import datetime
44
import re
5-
from typing import Any
65
import weakref
76

87
import numpy as np
@@ -596,7 +595,7 @@ def __str__(self) -> str:
596595

597596
__repr__ = __str__
598597

599-
def __eq__(self, other: Any) -> bool:
598+
def __eq__(self, other) -> bool:
600599
return self.value == other.value
601600

602601
def view(self):

pandas/tests/scalar/timedelta/test_timedelta.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
""" test the scalar Timedelta """
22
from datetime import timedelta
33
import re
4-
from typing import Any
54

65
import numpy as np
76
import pytest
@@ -134,7 +133,7 @@ def generic_result(self):
134133
else:
135134
return self.cmp_result
136135

137-
def __eq__(self, other: Any):
136+
def __eq__(self, other):
138137
return self.generic_result()
139138

140139
def __gt__(self, other):

pandas/tests/scalar/timestamp/test_comparisons.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from datetime import datetime
22
import operator
3-
from typing import Any
43

54
import numpy as np
65
import pytest
@@ -180,7 +179,7 @@ def __gt__(self, o):
180179
def __ge__(self, o):
181180
return True
182181

183-
def __eq__(self, other: Any) -> bool:
182+
def __eq__(self, other) -> bool:
184183
return isinstance(other, Inf)
185184

186185
inf = Inf()

pandas/tests/series/test_ufunc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections import deque
22
import string
3-
from typing import Any
43

54
import numpy as np
65
import pytest
@@ -283,7 +282,7 @@ def __add__(self, other):
283282
other = getattr(other, "value", other)
284283
return type(self)(self.value + other)
285284

286-
def __eq__(self, other: Any) -> bool:
285+
def __eq__(self, other) -> bool:
287286
return type(other) is Thing and self.value == other.value
288287

289288
def __repr__(self) -> str:

pandas/tests/test_algos.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime
22
from itertools import permutations
33
import struct
4-
from typing import Any
54

65
import numpy as np
76
from numpy.random import RandomState
@@ -768,7 +767,7 @@ def test_same_object_is_in(self):
768767
# with similar behavior, then we at least should
769768
# fall back to usual python's behavior: "a in [a] == True"
770769
class LikeNan:
771-
def __eq__(self, other: Any) -> bool:
770+
def __eq__(self, other) -> bool:
772771
return False
773772

774773
def __hash__(self):

pandas/tseries/offsets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import date, datetime, timedelta
22
import functools
33
import operator
4-
from typing import Any, Optional
4+
from typing import Optional
55

66
from dateutil.easter import easter
77
import numpy as np
@@ -2577,7 +2577,7 @@ def __add__(self, other):
25772577
"will overflow".format(self=self, other=other)
25782578
)
25792579

2580-
def __eq__(self, other: Any) -> bool:
2580+
def __eq__(self, other) -> bool:
25812581
if isinstance(other, str):
25822582
from pandas.tseries.frequencies import to_offset
25832583

0 commit comments

Comments
 (0)