Skip to content

Commit 2432afe

Browse files
committed
try to fix mypy on 3.10
1 parent 2d4ccf1 commit 2432afe

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class Timestamp(datetime, SupportsIndex):
260260
@overload
261261
def __eq__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
262262
@overload # TODO: using shape-aware arrays similar to other methods doesn't work in mypy
263-
def __eq__(self, other: npt.NDArray[np.datetime64]) -> npt.NDArray[np.bool]: ... # type: ignore[overload-overlap]
263+
def __eq__(self, other: npt.NDArray[np.datetime64]) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
264264
@overload
265265
def __eq__(self, other: object) -> Literal[False]: ...
266266
@overload
@@ -270,7 +270,7 @@ class Timestamp(datetime, SupportsIndex):
270270
@overload
271271
def __ne__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
272272
@overload # TODO: using shape-aware arrays similar to other methods doesn't work in mypy
273-
def __ne__(self, other: npt.NDArray[np.datetime64]) -> npt.NDArray[np.bool]: ... # type: ignore[overload-overlap]
273+
def __ne__(self, other: npt.NDArray[np.datetime64]) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
274274
@overload
275275
def __ne__(self, other: object) -> Literal[True]: ...
276276
def __hash__(self) -> int: ...

tests/test_scalars.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import datetime
44
import datetime as dt
5-
import sys
5+
6+
# import sys
67
from typing import (
78
TYPE_CHECKING,
89
Any,
@@ -1390,22 +1391,28 @@ def test_timestamp_cmp() -> None:
13901391
)
13911392
assert (eq_arr != ne_arr).all()
13921393

1393-
if sys.version_info >= (3, 11) or not MYPY:
1394+
if True: # sys.version_info >= (3, 11) or not MYPY:
13941395
# tests in this block fail with mypy on Python 3.10 in CI only
13951396
# I couldn't reproduce the failure locally so skip mypy on Python 3.10
13961397
eq_arr = check(
1397-
assert_type(ts == c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1398+
assert_type(ts == c_np_ndarray_dt64, np_1darray[np.bool]),
1399+
np_1darray[np.bool],
1400+
np.bool_,
13981401
)
13991402
ne_arr = check(
1400-
assert_type(ts != c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1403+
assert_type(ts != c_np_ndarray_dt64, np_1darray[np.bool]),
1404+
np_1darray[np.bool],
1405+
np.bool_,
14011406
)
14021407
assert (eq_arr != ne_arr).all()
14031408
# TODO: the following should be 2D-arrays but it doesn't work in mypy
14041409
eq_arr = check(
1405-
assert_type(ts == c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool
1410+
assert_type(ts == c_np_2darray_dt64, np_1darray[np.bool]),
1411+
np_1darray[np.bool],
14061412
)
14071413
ne_arr = check(
1408-
assert_type(ts != c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool
1414+
assert_type(ts != c_np_2darray_dt64, np_1darray[np.bool]),
1415+
np_1darray[np.bool],
14091416
)
14101417
assert (eq_arr != ne_arr).all()
14111418

0 commit comments

Comments
 (0)