From 489f757d89961dd48072d186ebbf9c845cb784dc Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Tue, 26 Nov 2019 01:13:50 +0200 Subject: [PATCH] Added 'object' annotation to 'other' --- pandas/_libs/tslibs/offsets.pyx | 2 +- pandas/core/arrays/sparse/dtype.py | 2 +- pandas/core/dtypes/base.py | 2 +- pandas/core/dtypes/dtypes.py | 8 ++++---- pandas/core/indexes/frozen.py | 2 +- pandas/io/pytables.py | 4 ++-- pandas/io/stata.py | 2 +- pandas/tests/groupby/test_function.py | 2 +- pandas/tests/indexing/test_indexing.py | 2 +- pandas/tests/scalar/timedelta/test_timedelta.py | 2 +- pandas/tests/scalar/timestamp/test_comparisons.py | 2 +- pandas/tests/series/test_ufunc.py | 2 +- pandas/tests/test_algos.py | 2 +- pandas/tseries/offsets.py | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 327d1067dd17d..9ea0f94c86e41 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -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 diff --git a/pandas/core/arrays/sparse/dtype.py b/pandas/core/arrays/sparse/dtype.py index 3b656705f5568..994f210d0f017 100644 --- a/pandas/core/arrays/sparse/dtype.py +++ b/pandas/core/arrays/sparse/dtype.py @@ -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): diff --git a/pandas/core/dtypes/base.py b/pandas/core/dtypes/base.py index 8acdf32c8768e..157f990f08243 100644 --- a/pandas/core/dtypes/base.py +++ b/pandas/core/dtypes/base.py @@ -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. diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 2c601b01dbae5..d758ce7267d06 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -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' @@ -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 @@ -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() @@ -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): diff --git a/pandas/core/indexes/frozen.py b/pandas/core/indexes/frozen.py index 13c386187a9e5..e4e68f7fdfb72 100644 --- a/pandas/core/indexes/frozen.py +++ b/pandas/core/indexes/frozen.py @@ -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) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 99cfb22b9921f..e2a9ca299d799 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -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) @@ -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) diff --git a/pandas/io/stata.py b/pandas/io/stata.py index bd5e215730397..42c4f76c749d4 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -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 diff --git a/pandas/tests/groupby/test_function.py b/pandas/tests/groupby/test_function.py index c41f762e9128d..550954564ac0c 100644 --- a/pandas/tests/groupby/test_function.py +++ b/pandas/tests/groupby/test_function.py @@ -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) diff --git a/pandas/tests/indexing/test_indexing.py b/pandas/tests/indexing/test_indexing.py index 8e52d2cca7070..25985c0004ef9 100644 --- a/pandas/tests/indexing/test_indexing.py +++ b/pandas/tests/indexing/test_indexing.py @@ -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): diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py index 9bb6c991a930a..db8a97c8adbb2 100644 --- a/pandas/tests/scalar/timedelta/test_timedelta.py +++ b/pandas/tests/scalar/timedelta/test_timedelta.py @@ -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): diff --git a/pandas/tests/scalar/timestamp/test_comparisons.py b/pandas/tests/scalar/timestamp/test_comparisons.py index da0818c5dc596..ea41e8ed76469 100644 --- a/pandas/tests/scalar/timestamp/test_comparisons.py +++ b/pandas/tests/scalar/timestamp/test_comparisons.py @@ -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() diff --git a/pandas/tests/series/test_ufunc.py b/pandas/tests/series/test_ufunc.py index 977e7ded1f1a7..fe5e044f3b92e 100644 --- a/pandas/tests/series/test_ufunc.py +++ b/pandas/tests/series/test_ufunc.py @@ -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: diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index 02b50d84c6eca..62111be6a6d21 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -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): diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 0620f2b9aae49..28a5584b00cc3 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -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