From c423bc0b8a487b61f98faf63e29c5f0e8aadbd5a Mon Sep 17 00:00:00 2001 From: alexander-beedie Date: Tue, 18 Jun 2024 20:58:20 +0400 Subject: [PATCH] fix(python): Some `Series` dunder method type signatures --- py-polars/polars/series/series.py | 12 ++++++------ py-polars/tests/unit/series/test_series.py | 12 +++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index d843e9baef1c..7ba1f9dab824 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -596,32 +596,32 @@ def __repr__(self) -> str: def __len__(self) -> int: return self.len() - def __and__(self, other: Series) -> Self: + def __and__(self, other: Any) -> Self: if not isinstance(other, Series): other = Series([other]) return self._from_pyseries(self._s.bitand(other._s)) - def __rand__(self, other: Series) -> Series: + def __rand__(self, other: Any) -> Series: if not isinstance(other, Series): other = Series([other]) return other & self - def __or__(self, other: Series) -> Self: + def __or__(self, other: Any) -> Self: if not isinstance(other, Series): other = Series([other]) return self._from_pyseries(self._s.bitor(other._s)) - def __ror__(self, other: Series) -> Series: + def __ror__(self, other: Any) -> Series: if not isinstance(other, Series): other = Series([other]) return other | self - def __xor__(self, other: Series) -> Self: + def __xor__(self, other: Any) -> Self: if not isinstance(other, Series): other = Series([other]) return self._from_pyseries(self._s.bitxor(other._s)) - def __rxor__(self, other: Series) -> Series: + def __rxor__(self, other: Any) -> Series: if not isinstance(other, Series): other = Series([other]) return other ^ self diff --git a/py-polars/tests/unit/series/test_series.py b/py-polars/tests/unit/series/test_series.py index 9613634bd420..e28009651b40 100644 --- a/py-polars/tests/unit/series/test_series.py +++ b/py-polars/tests/unit/series/test_series.py @@ -277,21 +277,15 @@ def test_bitwise_ops() -> None: # Note that the type annotations only allow Series to be passed in, but there is # specific code to deal with non-Series inputs. assert_series_equal( - ( - True & a # type: ignore[operator] - ), + (True & a), pl.Series([True, False, True]), ) assert_series_equal( - ( - True | a # type: ignore[operator] - ), + (True | a), pl.Series([True, True, True]), ) assert_series_equal( - ( - True ^ a # type: ignore[operator] - ), + (True ^ a), pl.Series([False, True, False]), )