Skip to content

Commit

Permalink
fix(python): Some Series dunder method type signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Jun 18, 2024
1 parent 2aec475 commit c423bc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
12 changes: 6 additions & 6 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions py-polars/tests/unit/series/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
)

Expand Down

0 comments on commit c423bc0

Please sign in to comment.