Skip to content

Commit 6e67867

Browse files
committed
old numpy
1 parent cff1f76 commit 6e67867

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/indexes/test_indexes.py

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

33
from collections.abc import Hashable
44
import datetime as dt
5+
import sys
56
from typing import (
67
Any,
78
cast,
@@ -1675,10 +1676,13 @@ def test_index_view() -> None:
16751676
ind = pd.Index([1, 2])
16761677
check(assert_type(ind.view("int64"), ArrayLike), np_1darray_int64)
16771678
check(assert_type(ind.view(), "pd.Index[int]"), pd.Index)
1678-
# mypy and pyright differ here in what they report:
1679-
# - mypy: ndarray[Any, Any]"
1680-
# - pyright: ndarray[tuple[Any, ...], dtype[Any]]
1681-
check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type]
1679+
# on NumPy<1.23, we get:
1680+
# error: "assert_type" mismatch: expected "ndarray[tuple[Any, ...], dtype[Any]]" but received "ndarray[Unknown, Unknown]" (reportAssertTypeFailure)
1681+
if sys.version_info >= (3, 11):
1682+
# mypy and pyright differ here in what they report:
1683+
# - mypy: ndarray[Any, Any]"
1684+
# - pyright: ndarray[tuple[Any, ...], dtype[Any]]
1685+
check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type]
16821686

16831687
class MyArray(np.ndarray): ...
16841688

0 commit comments

Comments
 (0)