Skip to content

Commit 63dfe96

Browse files
Add MaskType to other cases (#1073)
* 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
1 parent e943bd4 commit 63dfe96

File tree

5 files changed

+14
-38
lines changed

5 files changed

+14
-38
lines changed

pandas-stubs/core/indexes/base.pyi

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ from pandas._typing import (
4848
HashableT,
4949
Label,
5050
Level,
51+
MaskType,
5152
NaPosition,
5253
TimedeltaDtypeArg,
5354
TimestampDtypeArg,
@@ -368,15 +369,7 @@ class Index(IndexOpsMixin[S1]):
368369
@overload
369370
def __getitem__(
370371
self,
371-
idx: (
372-
slice
373-
| np_ndarray_anyint
374-
| Sequence[int]
375-
| Index
376-
| Series[bool]
377-
| Sequence[bool]
378-
| np_ndarray_bool
379-
),
372+
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
380373
) -> Self: ...
381374
@overload
382375
def __getitem__(self, idx: int | tuple[np_ndarray_anyint, ...]) -> S1: ...

pandas-stubs/core/indexes/interval.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import pandas as pd
1313
from pandas import Index
1414
from pandas.core.indexes.extension import ExtensionIndex
1515
from pandas.core.series import (
16-
Series,
1716
TimedeltaSeries,
1817
TimestampSeries,
1918
)
@@ -31,6 +30,7 @@ from pandas._typing import (
3130
IntervalClosedType,
3231
IntervalT,
3332
Label,
33+
MaskType,
3434
np_ndarray_anyint,
3535
np_ndarray_bool,
3636
npt,
@@ -254,7 +254,7 @@ class IntervalIndex(ExtensionIndex[IntervalT], IntervalMixin):
254254
| np_ndarray_anyint
255255
| Sequence[int]
256256
| Index
257-
| Series[bool]
257+
| MaskType
258258
| np_ndarray_bool
259259
),
260260
) -> IntervalIndex[IntervalT]: ...

pandas-stubs/core/indexes/multi.pyi

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ from pandas._typing import (
1818
Dtype,
1919
DtypeArg,
2020
HashableT,
21+
MaskType,
2122
np_ndarray_anyint,
2223
np_ndarray_bool,
2324
)
@@ -114,15 +115,7 @@ class MultiIndex(Index[Any]):
114115
@overload # type: ignore[override]
115116
def __getitem__(
116117
self,
117-
idx: (
118-
slice
119-
| np_ndarray_anyint
120-
| Sequence[int]
121-
| Index
122-
| pd.Series[bool]
123-
| Sequence[bool]
124-
| np_ndarray_bool
125-
),
118+
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
126119
) -> Self: ...
127120
@overload
128121
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]

pandas-stubs/core/indexes/range.pyi

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ from collections.abc import Sequence
22
from typing import overload
33

44
import numpy as np
5-
from pandas import Series
65
from pandas.core.indexes.base import Index
76

87
from pandas._typing import (
98
HashableT,
9+
MaskType,
1010
np_ndarray_anyint,
11-
np_ndarray_bool,
1211
npt,
1312
)
1413

@@ -73,15 +72,7 @@ class RangeIndex(Index[int]):
7372
@overload # type: ignore[override]
7473
def __getitem__(
7574
self,
76-
idx: (
77-
slice
78-
| np_ndarray_anyint
79-
| Sequence[int]
80-
| Index
81-
| Series[bool]
82-
| Sequence[bool]
83-
| np_ndarray_bool
84-
),
75+
idx: slice | np_ndarray_anyint | Sequence[int] | Index | MaskType,
8576
) -> Index: ...
8677
@overload
8778
def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]

pandas-stubs/core/series.pyi

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ from pandas._typing import (
152152
VoidDtypeArg,
153153
WriteBuffer,
154154
np_ndarray_anyint,
155-
np_ndarray_bool,
156155
npt,
157156
num,
158157
)
@@ -1544,7 +1543,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
15441543
# ignore needed for mypy as we want different results based on the arguments
15451544
@overload # type: ignore[override]
15461545
def __and__( # pyright: ignore[reportOverlappingOverload]
1547-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1546+
self, other: bool | list[int] | MaskType
15481547
) -> Series[bool]: ...
15491548
@overload
15501549
def __and__( # pyright: ignore[reportIncompatibleMethodOverride]
@@ -1578,7 +1577,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
15781577
# ignore needed for mypy as we want different results based on the arguments
15791578
@overload # type: ignore[override]
15801579
def __or__( # pyright: ignore[reportOverlappingOverload]
1581-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1580+
self, other: bool | list[int] | MaskType
15821581
) -> Series[bool]: ...
15831582
@overload
15841583
def __or__( # pyright: ignore[reportIncompatibleMethodOverride]
@@ -1591,7 +1590,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
15911590
# ignore needed for mypy as we want different results based on the arguments
15921591
@overload # type: ignore[override]
15931592
def __rand__( # pyright: ignore[reportOverlappingOverload]
1594-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1593+
self, other: bool | MaskType | list[int]
15951594
) -> Series[bool]: ...
15961595
@overload
15971596
def __rand__( # pyright: ignore[reportIncompatibleMethodOverride]
@@ -1612,7 +1611,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
16121611
# ignore needed for mypy as we want different results based on the arguments
16131612
@overload # type: ignore[override]
16141613
def __ror__( # pyright: ignore[reportOverlappingOverload]
1615-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1614+
self, other: bool | MaskType | list[int]
16161615
) -> Series[bool]: ...
16171616
@overload
16181617
def __ror__( # pyright: ignore[reportIncompatibleMethodOverride]
@@ -1623,7 +1622,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
16231622
# ignore needed for mypy as we want different results based on the arguments
16241623
@overload # type: ignore[override]
16251624
def __rxor__( # pyright: ignore[reportOverlappingOverload]
1626-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1625+
self, other: bool | MaskType | list[int]
16271626
) -> Series[bool]: ...
16281627
@overload
16291628
def __rxor__( # pyright: ignore[reportIncompatibleMethodOverride]
@@ -1649,7 +1648,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
16491648
# ignore needed for mypy as we want different results based on the arguments
16501649
@overload # type: ignore[override]
16511650
def __xor__( # pyright: ignore[reportOverlappingOverload]
1652-
self, other: bool | list[bool] | list[int] | np_ndarray_bool | Series[bool]
1651+
self, other: bool | MaskType | list[int]
16531652
) -> Series[bool]: ...
16541653
@overload
16551654
def __xor__( # pyright: ignore[reportIncompatibleMethodOverride]

0 commit comments

Comments
 (0)