Skip to content

Commit 7446db3

Browse files
authored
TYP: algos.isin (#53479)
1 parent 07858c2 commit 7446db3

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

pandas/core/algorithms.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383

8484
if TYPE_CHECKING:
8585
from pandas._typing import (
86+
ListLike,
8687
NumpySorter,
8788
NumpyValueArrayLike,
8889
)
@@ -438,14 +439,14 @@ def unique_with_mask(values, mask: npt.NDArray[np.bool_] | None = None):
438439
unique1d = unique
439440

440441

441-
def isin(comps: AnyArrayLike, values: AnyArrayLike) -> npt.NDArray[np.bool_]:
442+
def isin(comps: ListLike, values: ListLike) -> npt.NDArray[np.bool_]:
442443
"""
443444
Compute the isin boolean array.
444445
445446
Parameters
446447
----------
447-
comps : array-like
448-
values : array-like
448+
comps : list-like
449+
values : list-like
449450
450451
Returns
451452
-------

pandas/core/tools/datetimes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,7 @@ def calc_with_mask(carg, mask):
12521252

12531253
# string with NaN-like
12541254
try:
1255-
# error: Argument 2 to "isin" has incompatible type "List[Any]"; expected
1256-
# "Union[Union[ExtensionArray, ndarray], Index, Series]"
1257-
mask = ~algorithms.isin(arg, list(nat_strings)) # type: ignore[arg-type]
1255+
mask = ~algorithms.isin(arg, list(nat_strings))
12581256
return calc_with_mask(arg, mask)
12591257
except (ValueError, OverflowError, TypeError):
12601258
pass

pandas/io/parsers/base_parser.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,7 @@ def _convert_to_ndarrays(
558558
try:
559559
values = lib.map_infer(values, conv_f)
560560
except ValueError:
561-
# error: Argument 2 to "isin" has incompatible type "List[Any]";
562-
# expected "Union[Union[ExtensionArray, ndarray], Index, Series]"
563-
mask = algorithms.isin(
564-
values, list(na_values) # type: ignore[arg-type]
565-
).view(np.uint8)
561+
mask = algorithms.isin(values, list(na_values)).view(np.uint8)
566562
values = lib.map_infer_mask(values, conv_f, mask)
567563

568564
cvals, na_count = self._infer_types(

0 commit comments

Comments
 (0)