Skip to content

Commit 07cd485

Browse files
committed
add overloads for multiindex.isin
1 parent b47951a commit 07cd485

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pandas-stubs/core/indexes/multi.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@ class MultiIndex(Index):
165165
def equal_levels(self, other): ...
166166
def insert(self, loc, item): ...
167167
def delete(self, loc): ...
168-
def isin(self, values, level=...) -> np_1darray_bool: ...
168+
@overload # type: ignore[override]
169+
def isin(self, values: Iterable[Any], level: Level) -> np_1darray_bool: ...
170+
@overload
171+
def isin(
172+
self, values: Iterable[Iterable[Any]], level: None = None
173+
) -> np_1darray_bool: ... # pyright: ignore[reportIncompatibleMethodOverride]
169174
def set_names(
170175
self,
171176
names: Hashable | Sequence[Hashable] | Mapping[Any, Hashable],

tests/indexes/test_indexes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def test_index_isin() -> None:
6262
check(assert_type(ind.isin(pd.Index([2, 4])), np_1darray_bool), np_1darray_bool)
6363
check(assert_type(ind.isin(iter([2, "4"])), np_1darray_bool), np_1darray_bool)
6464

65+
mi = pd.MultiIndex.from_arrays([[1, 2, 3]])
66+
check(assert_type(mi.isin([[3]]), np_1darray_bool), np_1darray_bool)
67+
if TYPE_CHECKING_INVALID_USAGE:
68+
mi.isin({3}) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
69+
6570

6671
def test_index_astype() -> None:
6772
indi = pd.Index([1, 2, 3])

0 commit comments

Comments
 (0)