Skip to content

Commit abfef56

Browse files
committed
See if renaming variables work
1 parent 2d4ccf1 commit abfef56

File tree

4 files changed

+37
-43
lines changed

4 files changed

+37
-43
lines changed

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ from pandas._typing import (
4545
TimeUnit,
4646
np_1darray,
4747
np_ndarray,
48-
npt,
4948
)
5049

5150
_Ambiguous: TypeAlias = bool | Literal["raise", "NaT"]
@@ -259,8 +258,8 @@ class Timestamp(datetime, SupportsIndex):
259258
def __eq__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
260259
@overload
261260
def __eq__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
262-
@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]
261+
@overload
262+
def __eq__(self, other: np_ndarray[ShapeT, np.datetime64]) -> np_ndarray[ShapeT, np.bool]: ... # type: ignore[overload-overlap]
264263
@overload
265264
def __eq__(self, other: object) -> Literal[False]: ...
266265
@overload
@@ -269,8 +268,8 @@ class Timestamp(datetime, SupportsIndex):
269268
def __ne__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
270269
@overload
271270
def __ne__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
272-
@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]
271+
@overload
272+
def __ne__(self, other: np_ndarray[ShapeT, np.datetime64]) -> np_ndarray[ShapeT, np.bool]: ... # type: ignore[overload-overlap]
274273
@overload
275274
def __ne__(self, other: object) -> Literal[True]: ...
276275
def __hash__(self) -> int: ...

pandas-stubs/core/dtypes/missing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def notna(obj: Index | ExtensionArray | list[ScalarT]) -> np_1darray[np.bool]: .
5252
@overload
5353
def notna(obj: np_ndarray[ShapeT]) -> np_ndarray[ShapeT, np.bool]: ...
5454
@overload
55-
def notna(obj: Index | list[Any]) -> np_ndarray_bool: ...
55+
def notna(obj: list[Any]) -> np_ndarray_bool: ...
5656
@overload
5757
def notna(obj: ScalarT | NaTType | NAType | None) -> TypeIs[ScalarT]: ...
5858

tests/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
TYPE_CHECKING,
1212
Final,
1313
Literal,
14+
TypeAlias,
1415
TypeVar,
1516
get_args,
1617
get_origin,
@@ -51,10 +52,10 @@
5152
else:
5253
_G = TypeVar("_G", bound=np.generic)
5354
# Separately define here so pytest works
54-
np_1darray = np.ndarray[tuple[int], np.dtype[_G]]
55-
np_2darray = np.ndarray[tuple[int, int], np.dtype[_G]]
56-
np_ndarray_bool = npt.NDArray[np.bool_]
57-
np_ndarray_int = npt.NDArray[np.signedinteger]
55+
np_1darray: TypeAlias = np.ndarray[tuple[int], np.dtype[_G]]
56+
np_2darray: TypeAlias = np.ndarray[tuple[int, int], np.dtype[_G]]
57+
np_ndarray_bool: TypeAlias = npt.NDArray[np.bool_]
58+
np_ndarray_int: TypeAlias = npt.NDArray[np.signedinteger]
5859

5960
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
6061
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()

tests/test_scalars.py

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

33
import datetime
44
import datetime as dt
5-
import sys
65
from typing import (
76
TYPE_CHECKING,
87
Any,
@@ -52,8 +51,6 @@
5251
PeriodSeries: TypeAlias = pd.Series
5352
OffsetSeries: TypeAlias = pd.Series
5453

55-
MYPY = False
56-
5754

5855
def test_interval() -> None:
5956
interval_i = pd.Interval(0, 1, closed="left")
@@ -1375,55 +1372,52 @@ def test_timestamp_cmp() -> None:
13751372
ne = check(assert_type(ts != c_dt_datetime, bool), bool)
13761373
assert eq != ne
13771374

1378-
eq_arr = check(
1375+
eq_arr1 = check(
13791376
assert_type(ts == c_datetimeindex, np_1darray[np.bool]), np_1darray[np.bool]
13801377
)
1381-
ne_arr = check(
1378+
ne_arr1 = check(
13821379
assert_type(ts != c_datetimeindex, np_1darray[np.bool]), np_1darray[np.bool]
13831380
)
1384-
assert (eq_arr != ne_arr).all()
1385-
eq_arr = check(
1381+
assert (eq_arr1 != ne_arr1).all()
1382+
eq_arr2 = check(
13861383
assert_type(ts == c_unknown_index, np_1darray[np.bool]), np_1darray[np.bool]
13871384
)
1388-
ne_arr = check(
1385+
ne_arr2 = check(
13891386
assert_type(ts != c_unknown_index, np_1darray[np.bool]), np_1darray[np.bool]
13901387
)
1391-
assert (eq_arr != ne_arr).all()
1388+
assert (eq_arr2 != ne_arr2).all()
13921389

1393-
if sys.version_info >= (3, 11) or not MYPY:
1394-
# tests in this block fail with mypy on Python 3.10 in CI only
1395-
# I couldn't reproduce the failure locally so skip mypy on Python 3.10
1396-
eq_arr = check(
1397-
assert_type(ts == c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1398-
)
1399-
ne_arr = check(
1400-
assert_type(ts != c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1401-
)
1402-
assert (eq_arr != ne_arr).all()
1403-
# TODO: the following should be 2D-arrays but it doesn't work in mypy
1404-
eq_arr = check(
1405-
assert_type(ts == c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool
1406-
)
1407-
ne_arr = check(
1408-
assert_type(ts != c_np_2darray_dt64, np_ndarray_bool), np_ndarray_bool
1409-
)
1410-
assert (eq_arr != ne_arr).all()
1390+
eq_arr3 = check(
1391+
assert_type(ts == c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1392+
)
1393+
ne_arr3 = check(
1394+
assert_type(ts != c_np_ndarray_dt64, np_ndarray_bool), np.ndarray, np.bool_
1395+
)
1396+
assert (eq_arr3 != ne_arr3).all()
14111397

1412-
eq_s = check(
1398+
eq_arr4 = check(
1399+
assert_type(ts == c_np_2darray_dt64, np_2darray[np.bool]), np_2darray[np.bool]
1400+
)
1401+
ne_arr4 = check(
1402+
assert_type(ts != c_np_2darray_dt64, np_2darray[np.bool]), np_2darray[np.bool]
1403+
)
1404+
assert (eq_arr4 != ne_arr4).all()
1405+
1406+
eq_s1 = check(
14131407
assert_type(ts == c_series_timestamp, "pd.Series[bool]"), pd.Series, np.bool_
14141408
)
1415-
ne_s = check(
1409+
ne_s1 = check(
14161410
assert_type(ts != c_series_timestamp, "pd.Series[bool]"), pd.Series, np.bool_
14171411
)
1418-
assert (eq_s != ne_s).all()
1412+
assert (eq_s1 != ne_s1).all()
14191413

1420-
eq_s = check(
1414+
eq_s2 = check(
14211415
assert_type(ts == c_series_dt64, "pd.Series[bool]"), pd.Series, np.bool_
14221416
)
1423-
ne_s = check(
1417+
ne_s2 = check(
14241418
assert_type(ts != c_series_dt64, "pd.Series[bool]"), pd.Series, np.bool_
14251419
)
1426-
assert (eq_s != ne_s).all()
1420+
assert (eq_s2 != ne_s2).all()
14271421

14281422

14291423
def test_timestamp_eq_ne_rhs() -> None:

0 commit comments

Comments
 (0)