Skip to content

Commit

Permalink
Add MaskType to other cases (#1073)
Browse files Browse the repository at this point in the history
* Lock numpy upper bound version due to bug in version 2.2.0

* Replace Series[bool] and alike with MaskType

* More replacemens in pandas-stubs/core/series.pyi
  • Loading branch information
loicdiridollou authored Dec 17, 2024
1 parent e943bd4 commit 63dfe96
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 38 deletions.
11 changes: 2 additions & 9 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ from pandas._typing import (
HashableT,
Label,
Level,
MaskType,
NaPosition,
TimedeltaDtypeArg,
TimestampDtypeArg,
Expand Down Expand Up @@ -368,15 +369,7 @@ class Index(IndexOpsMixin[S1]):
@overload
def __getitem__(
self,
idx: (
slice
| np_ndarray_anyint
| Sequence[int]
| Index
| Series[bool]
| Sequence[bool]
| np_ndarray_bool
),
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
) -> Self: ...
@overload
def __getitem__(self, idx: int | tuple[np_ndarray_anyint, ...]) -> S1: ...
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import pandas as pd
from pandas import Index
from pandas.core.indexes.extension import ExtensionIndex
from pandas.core.series import (
Series,
TimedeltaSeries,
TimestampSeries,
)
Expand All @@ -31,6 +30,7 @@ from pandas._typing import (
IntervalClosedType,
IntervalT,
Label,
MaskType,
np_ndarray_anyint,
np_ndarray_bool,
npt,
Expand Down Expand Up @@ -254,7 +254,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
| np_ndarray_anyint
| Sequence[int]
| Index
| Series[bool]
| MaskType
| np_ndarray_bool
),
) -> IntervalIndex[IntervalT]: ...
Expand Down
11 changes: 2 additions & 9 deletions pandas-stubs/core/indexes/multi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ from pandas._typing import (
Dtype,
DtypeArg,
HashableT,
MaskType,
np_ndarray_anyint,
np_ndarray_bool,
)
Expand Down Expand Up @@ -114,15 +115,7 @@ class MultiIndex(Index[Any]):
@overload # type: ignore[override]
def __getitem__(
self,
idx: (
slice
| np_ndarray_anyint
| Sequence[int]
| Index
| pd.Series[bool]
| Sequence[bool]
| np_ndarray_bool
),
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
) -> Self: ...
@overload
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down
13 changes: 2 additions & 11 deletions pandas-stubs/core/indexes/range.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ from collections.abc import Sequence
from typing import overload

import numpy as np
from pandas import Series
from pandas.core.indexes.base import Index

from pandas._typing import (
HashableT,
MaskType,
np_ndarray_anyint,
np_ndarray_bool,
npt,
)

Expand Down Expand Up @@ -73,15 +72,7 @@ class RangeIndex(Index[int]):
@overload # type: ignore[override]
def __getitem__(
self,
idx: (
slice
| np_ndarray_anyint
| Sequence[int]
| Index
| Series[bool]
| Sequence[bool]
| np_ndarray_bool
),
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
) -> Index: ...
@overload
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down
13 changes: 6 additions & 7 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ from pandas._typing import (
VoidDtypeArg,
WriteBuffer,
np_ndarray_anyint,
np_ndarray_bool,
npt,
num,
)
Expand Down Expand Up @@ -1544,7 +1543,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __and__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | list[int] | MaskType
) -> Series[bool]: ...
@overload
def __and__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down Expand Up @@ -1578,7 +1577,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __or__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | list[int] | MaskType
) -> Series[bool]: ...
@overload
def __or__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -1591,7 +1590,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __rand__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | MaskType | list[int]
) -> Series[bool]: ...
@overload
def __rand__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -1612,7 +1611,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __ror__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | MaskType | list[int]
) -> Series[bool]: ...
@overload
def __ror__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -1623,7 +1622,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __rxor__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | MaskType | list[int]
) -> Series[bool]: ...
@overload
def __rxor__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand All @@ -1649,7 +1648,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
# ignore needed for mypy as we want different results based on the arguments
@overload # type: ignore[override]
def __xor__( # pyright: ignore[reportOverlappingOverload]
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
self, other: bool | MaskType | list[int]
) -> Series[bool]: ...
@overload
def __xor__( # pyright: ignore[reportIncompatibleMethodOverride]
Expand Down

0 comments on commit 63dfe96

Please sign in to comment.