@@ -713,8 +713,16 @@ def test_timedelta_mul_div() -> None:
713
713
714
714
check (assert_type (md_int * td , pd .Timedelta ), pd .Timedelta )
715
715
check (assert_type (md_float * td , pd .Timedelta ), pd .Timedelta )
716
- check (assert_type (md_ndarray_intp * td , np .ndarray ), np .ndarray , np .timedelta64 )
717
- check (assert_type (md_ndarray_float * td , np .ndarray ), np .ndarray , np .timedelta64 )
716
+ check (
717
+ assert_type (md_ndarray_intp * td , npt .NDArray [np .timedelta64 ]),
718
+ np .ndarray ,
719
+ np .timedelta64 ,
720
+ )
721
+ check (
722
+ assert_type (md_ndarray_float * td , npt .NDArray [np .timedelta64 ]),
723
+ np .ndarray ,
724
+ np .timedelta64 ,
725
+ )
718
726
check (assert_type (mp_series_int * td , TimedeltaSeries ), pd .Series , pd .Timedelta )
719
727
check (assert_type (md_series_float * td , TimedeltaSeries ), pd .Series , pd .Timedelta )
720
728
check (assert_type (md_int64_index * td , pd .TimedeltaIndex ), pd .TimedeltaIndex )
@@ -1253,6 +1261,8 @@ def test_timestamp_cmp() -> None:
1253
1261
c_np_dt64 = np .datetime64 (1 , "ns" )
1254
1262
c_dt_datetime = dt .datetime (year = 2000 , month = 1 , day = 1 )
1255
1263
c_datetimeindex = pd .DatetimeIndex (["2000-1-1" ])
1264
+ # DatetimeIndex, but the type checker detects it to be UnknownIndex.
1265
+ c_unknown_index = pd .DataFrame ({"a" : [1 ]}, index = c_datetimeindex ).index
1256
1266
c_np_ndarray_dt64 = np_dt64_arr
1257
1267
c_series_dt64 : TimestampSeries = pd .Series ([1 , 2 , 3 ], dtype = "datetime64[ns]" )
1258
1268
c_series_timestamp = pd .Series (pd .DatetimeIndex (["2000-1-1" ]))
@@ -1273,6 +1283,8 @@ def test_timestamp_cmp() -> None:
1273
1283
1274
1284
check (assert_type (ts > c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
1275
1285
check (assert_type (ts <= c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
1286
+ check (assert_type (ts > c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_ )
1287
+ check (assert_type (ts <= c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_ )
1276
1288
1277
1289
check (assert_type (ts > c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
1278
1290
check (assert_type (ts <= c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1292,6 +1304,8 @@ def test_timestamp_cmp() -> None:
1292
1304
1293
1305
check (assert_type (c_datetimeindex > ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1294
1306
check (assert_type (c_datetimeindex <= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1307
+ check (assert_type (c_unknown_index > ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1308
+ check (assert_type (c_unknown_index <= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1295
1309
1296
1310
check (assert_type (c_np_ndarray_dt64 > ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1297
1311
check (assert_type (c_np_ndarray_dt64 <= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1313,6 +1327,8 @@ def test_timestamp_cmp() -> None:
1313
1327
1314
1328
check (assert_type (ts >= c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
1315
1329
check (assert_type (ts < c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
1330
+ check (assert_type (ts >= c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_ )
1331
+ check (assert_type (ts < c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_ )
1316
1332
1317
1333
check (assert_type (ts >= c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
1318
1334
check (assert_type (ts < c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1332,6 +1348,8 @@ def test_timestamp_cmp() -> None:
1332
1348
1333
1349
check (assert_type (c_datetimeindex >= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1334
1350
check (assert_type (c_datetimeindex < ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1351
+ check (assert_type (c_unknown_index >= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1352
+ check (assert_type (c_unknown_index < ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1335
1353
1336
1354
check (assert_type (c_np_ndarray_dt64 >= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
1337
1355
check (assert_type (c_np_ndarray_dt64 < ts , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1358,6 +1376,13 @@ def test_timestamp_cmp() -> None:
1358
1376
assert_type (ts != c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_
1359
1377
)
1360
1378
assert (eq_arr != ne_arr ).all ()
1379
+ eq_arr = check (
1380
+ assert_type (ts == c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_
1381
+ )
1382
+ ne_arr = check (
1383
+ assert_type (ts != c_unknown_index , np_ndarray_bool ), np .ndarray , np .bool_
1384
+ )
1385
+ assert (eq_arr != ne_arr ).all ()
1361
1386
1362
1387
eq_arr = check (
1363
1388
assert_type (ts == c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_
@@ -1396,6 +1421,8 @@ def test_timestamp_eq_ne_rhs() -> None:
1396
1421
c_np_dt64 = np .datetime64 (1 , "ns" )
1397
1422
c_dt_datetime = dt .datetime (year = 2000 , month = 1 , day = 1 )
1398
1423
c_datetimeindex = pd .DatetimeIndex (["2000-1-1" ])
1424
+ # DatetimeIndex, but the type checker detects it to be UnknownIndex.
1425
+ c_unknown_index = pd .DataFrame ({"a" : [1 ]}, index = c_datetimeindex ).index
1399
1426
c_np_ndarray_dt64 = np_dt64_arr
1400
1427
c_series_dt64 : pd .Series [pd .Timestamp ] = pd .Series (
1401
1428
[1 , 2 , 3 ], dtype = "datetime64[ns]"
@@ -1416,6 +1443,13 @@ def test_timestamp_eq_ne_rhs() -> None:
1416
1443
assert_type (c_datetimeindex != ts , np_ndarray_bool ), np .ndarray , np .bool_
1417
1444
)
1418
1445
assert (eq_arr != ne_arr ).all ()
1446
+ eq_arr = check (
1447
+ assert_type (c_unknown_index == ts , np_ndarray_bool ), np .ndarray , np .bool_
1448
+ )
1449
+ ne_arr = check (
1450
+ assert_type (c_unknown_index != ts , np_ndarray_bool ), np .ndarray , np .bool_
1451
+ )
1452
+ assert (eq_arr != ne_arr ).all ()
1419
1453
1420
1454
eq_a = check (assert_type (c_np_ndarray_dt64 != ts , Any ), np .ndarray , np .bool_ )
1421
1455
ne_a = check (assert_type (c_np_ndarray_dt64 == ts , Any ), np .ndarray , np .bool_ )
0 commit comments