@@ -713,8 +713,16 @@ def test_timedelta_mul_div() -> None:
713713
714714 check (assert_type (md_int * td , pd .Timedelta ), pd .Timedelta )
715715 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+ )
718726 check (assert_type (mp_series_int * td , TimedeltaSeries ), pd .Series , pd .Timedelta )
719727 check (assert_type (md_series_float * td , TimedeltaSeries ), pd .Series , pd .Timedelta )
720728 check (assert_type (md_int64_index * td , pd .TimedeltaIndex ), pd .TimedeltaIndex )
@@ -1253,6 +1261,8 @@ def test_timestamp_cmp() -> None:
12531261 c_np_dt64 = np .datetime64 (1 , "ns" )
12541262 c_dt_datetime = dt .datetime (year = 2000 , month = 1 , day = 1 )
12551263 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
12561266 c_np_ndarray_dt64 = np_dt64_arr
12571267 c_series_dt64 : TimestampSeries = pd .Series ([1 , 2 , 3 ], dtype = "datetime64[ns]" )
12581268 c_series_timestamp = pd .Series (pd .DatetimeIndex (["2000-1-1" ]))
@@ -1273,6 +1283,8 @@ def test_timestamp_cmp() -> None:
12731283
12741284 check (assert_type (ts > c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
12751285 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_ )
12761288
12771289 check (assert_type (ts > c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
12781290 check (assert_type (ts <= c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1292,6 +1304,8 @@ def test_timestamp_cmp() -> None:
12921304
12931305 check (assert_type (c_datetimeindex > ts , np_ndarray_bool ), np .ndarray , np .bool_ )
12941306 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_ )
12951309
12961310 check (assert_type (c_np_ndarray_dt64 > ts , np_ndarray_bool ), np .ndarray , np .bool_ )
12971311 check (assert_type (c_np_ndarray_dt64 <= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1313,6 +1327,8 @@ def test_timestamp_cmp() -> None:
13131327
13141328 check (assert_type (ts >= c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_ )
13151329 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_ )
13161332
13171333 check (assert_type (ts >= c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
13181334 check (assert_type (ts < c_np_ndarray_dt64 , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1332,6 +1348,8 @@ def test_timestamp_cmp() -> None:
13321348
13331349 check (assert_type (c_datetimeindex >= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
13341350 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_ )
13351353
13361354 check (assert_type (c_np_ndarray_dt64 >= ts , np_ndarray_bool ), np .ndarray , np .bool_ )
13371355 check (assert_type (c_np_ndarray_dt64 < ts , np_ndarray_bool ), np .ndarray , np .bool_ )
@@ -1358,6 +1376,13 @@ def test_timestamp_cmp() -> None:
13581376 assert_type (ts != c_datetimeindex , np_ndarray_bool ), np .ndarray , np .bool_
13591377 )
13601378 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 ()
13611386
13621387 eq_arr = check (
13631388 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:
13961421 c_np_dt64 = np .datetime64 (1 , "ns" )
13971422 c_dt_datetime = dt .datetime (year = 2000 , month = 1 , day = 1 )
13981423 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
13991426 c_np_ndarray_dt64 = np_dt64_arr
14001427 c_series_dt64 : pd .Series [pd .Timestamp ] = pd .Series (
14011428 [1 , 2 , 3 ], dtype = "datetime64[ns]"
@@ -1416,6 +1443,13 @@ def test_timestamp_eq_ne_rhs() -> None:
14161443 assert_type (c_datetimeindex != ts , np_ndarray_bool ), np .ndarray , np .bool_
14171444 )
14181445 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 ()
14191453
14201454 eq_a = check (assert_type (c_np_ndarray_dt64 != ts , Any ), np .ndarray , np .bool_ )
14211455 ne_a = check (assert_type (c_np_ndarray_dt64 == ts , Any ), np .ndarray , np .bool_ )
0 commit comments