Skip to content

Commit

Permalink
Added 'object' annotation to 'other'
Browse files Browse the repository at this point in the history
  • Loading branch information
MomIsBestFriend committed Nov 25, 2019
1 parent 4b9cc76 commit 489f757
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class _BaseOffset:
def __setattr__(self, name, value):
raise AttributeError("DateOffset objects are immutable.")

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
try:
# GH#23524 if to_offset fails, we are dealing with an
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/sparse/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __hash__(self):
# __eq__, so we explicitly do it here.
return super().__hash__()

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
# We have to override __eq__ to handle NA values in _metadata.
# The base class does simple == checks, which fail for NA.
if isinstance(other, str):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __from_arrow__(
def __str__(self) -> str:
return self.name

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
"""
Check whether 'other' is equal to self.
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def __hash__(self) -> int:
# We *do* want to include the real self.ordered here
return int(self._hash_categories(self.categories, self._ordered))

def __eq__(self, other: Any) -> bool:
def __eq__(self, other: object) -> bool:
"""
Rules for CDT equality:
1) Any CDT is equal to the string 'category'
Expand Down Expand Up @@ -765,7 +765,7 @@ def __hash__(self) -> int:
# TODO: update this.
return hash(str(self))

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
return other == self.name

Expand Down Expand Up @@ -904,7 +904,7 @@ def __hash__(self) -> int:
# make myself hashable
return hash(str(self))

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
return other == self.name or other == self.name.title()

Expand Down Expand Up @@ -1077,7 +1077,7 @@ def __hash__(self) -> int:
# make myself hashable
return hash(str(self))

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
return other.lower() in (self.name.lower(), str(self).lower())
elif not isinstance(other, IntervalDtype):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/frozen.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __radd__(self, other):
other = list(other)
return self.__class__(other + list(self))

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, (tuple, FrozenList)):
other = list(other)
return super().__eq__(other)
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ def __repr__(self) -> str:
)
)

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
""" compare 2 col items """
return all(
getattr(self, a, None) == getattr(other, a, None)
Expand Down Expand Up @@ -2109,7 +2109,7 @@ def __repr__(self) -> str:
)
)

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
""" compare 2 col items """
return all(
getattr(self, a, None) == getattr(other, a, None)
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ def __repr__(self) -> str:
# not perfect :-/
return "{cls}({obj})".format(cls=self.__class__, obj=self)

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
return (
isinstance(other, self.__class__)
and self.string == other.string
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ def __init__(self, msg="I will raise inside Cython"):
super().__init__()
self.msg = msg

def __eq__(self, other):
def __eq__(self, other: object):
# gets called in Cython to check that raising calls the method
raise RaisingObjectException(self.msg)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def __str__(self) -> str:

__repr__ = __str__

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
return self.value == other.value

def view(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/timedelta/test_timedelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def generic_result(self):
else:
return self.cmp_result

def __eq__(self, other):
def __eq__(self, other: object):
return self.generic_result()

def __gt__(self, other):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/timestamp/test_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def __gt__(self, o):
def __ge__(self, o):
return True

def __eq__(self, o) -> bool:
def __eq__(self, o: object) -> bool:
return isinstance(o, Inf)

inf = Inf()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def __add__(self, other):
other = getattr(other, "value", other)
return type(self)(self.value + other)

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
return type(other) is Thing and self.value == other.value

def __repr__(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def test_same_object_is_in(self):
# with similar behavior, then we at least should
# fall back to usual python's behavior: "a in [a] == True"
class LikeNan:
def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
return False

def __hash__(self):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ def __add__(self, other):
"will overflow".format(self=self, other=other)
)

def __eq__(self, other) -> bool:
def __eq__(self, other: object) -> bool:
if isinstance(other, str):
from pandas.tseries.frequencies import to_offset

Expand Down

0 comments on commit 489f757

Please sign in to comment.