Skip to content

Commit 6255df5

Browse files
authored
BUG: 🌃 mypy nightly (#1764)
* fix: python/mypy#21497 * fix: one more issue * chore: black * fix: attempt to fix mypy nightly * fix: relax type[np.bool_] to type[np.bool], which means type[np.bool[Any]] * fix: python/mypy#21608
1 parent 3937ee8 commit 6255df5

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎pandas-stubs/_typing.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ BuiltinBooleanDtypeArg: TypeAlias = type[bool] | Literal["bool"]
237237
PandasBooleanDtypeArg: TypeAlias = pd.BooleanDtype | Literal["boolean"]
238238
# Numpy bool type
239239
# https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.bool_
240-
NumpyBooleanDtypeArg: TypeAlias = type[np.bool_] | Literal["?", "b1", "bool_"]
240+
NumpyBooleanDtypeArg: TypeAlias = type[np.bool] | Literal["?", "b1", "bool_"]
241241
# PyArrow boolean type and its string alias
242242
PyArrowBooleanDtypeArg: TypeAlias = Literal["bool[pyarrow]", "boolean[pyarrow]"]
243243
BooleanDtypeArg: TypeAlias = (

‎tests/indexes/test_indexes.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,8 @@ def test_index_droplevel() -> None:
16811681
if TYPE_CHECKING_INVALID_USAGE:
16821682
idx.droplevel() # type: ignore[call-arg] # pyright: ignore[reportCallIssue]
16831683
idx.droplevel(0) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
1684-
idx.droplevel([0]) # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
1684+
# TODO: the following change is caused by python/mypy#21497. Remove unused-ignore after mypy 2.2.0.
1685+
idx.droplevel([0]) # type: ignore[arg-type,list-item,unused-ignore] # pyright: ignore[reportArgumentType]
16851686
idx.droplevel("name") # type: ignore[arg-type] # pyright: ignore[reportArgumentType]
16861687

16871688

‎tests/series/test_series.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,14 @@ def test_types_to_numpy() -> None:
21052105
np.bool_,
21062106
)
21072107
check(
2108-
assert_type(s_td_small.to_numpy(dtype=np.bool_), np_1darray[np.bool_]),
2108+
# TODO: python/mypy#21608
2109+
assert_type(s_td_small.to_numpy(dtype=np.bool), np_1darray_bool), # type: ignore[assert-type,unused-ignore]
2110+
np_1darray,
2111+
np.bool_,
2112+
)
2113+
check(
2114+
# TODO: python/mypy#21608
2115+
assert_type(s_td_small.to_numpy(dtype=np.bool_), np_1darray_bool), # type: ignore[assert-type,unused-ignore]
21092116
np_1darray,
21102117
np.bool_,
21112118
)
@@ -2382,7 +2389,7 @@ def test_types_to_numpy() -> None:
23822389
np.str_,
23832390
)
23842391
check(
2385-
assert_type(s_td_small.to_numpy(dtype=np.str_), np_1darray[np.str_]),
2392+
assert_type(s_td_small.to_numpy(dtype=np.str_), np_1darray_str),
23862393
np_1darray,
23872394
np.str_,
23882395
)
@@ -2628,9 +2635,7 @@ def test_types_to_numpy() -> None:
26282635
)
26292636
# np.dtypes.StrDType(size) — fixed-width unicode
26302637
check(
2631-
assert_type(
2632-
s_td_small.to_numpy(dtype=np.dtypes.StrDType(4)), np_1darray[np.str_]
2633-
),
2638+
assert_type(s_td_small.to_numpy(dtype=np.dtypes.StrDType(4)), np_1darray_str),
26342639
np_1darray,
26352640
np.str_,
26362641
)

0 commit comments

Comments
 (0)