Skip to content

Commit 4e21a31

Browse files
authored
adjust test for slice due to typeshed changes (#1067)
* adjust test for slice due to typeshed changes * comment out the previous test
1 parent 4529b51 commit 4e21a31

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/test_frame.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,14 @@ def test_indexslice_getitem():
23982398
.set_index(["x", "y"])
23992399
)
24002400
ind = pd.Index([2, 3])
2401-
check(assert_type(pd.IndexSlice[ind, :], tuple["pd.Index[int]", slice]), tuple)
2401+
# This next test is written this way to support both mypy 1.13 and newer
2402+
# versions of mypy and pyright that treat slice as a Generic due to
2403+
# a change in typeshed.
2404+
# Once pyright 1.1.390 and mypy 1.14 are released, the test can be
2405+
# reverted to the standard form.
2406+
# check(assert_type(pd.IndexSlice[ind, :], tuple["pd.Index[int]", slice]), tuple)
2407+
tmp: tuple[pd.Index[int], slice] = pd.IndexSlice[ind, :]
2408+
check(assert_type(tmp, tuple["pd.Index[int]", slice]), tuple)
24022409
check(assert_type(df.loc[pd.IndexSlice[ind, :]], pd.DataFrame), pd.DataFrame)
24032410
check(assert_type(df.loc[pd.IndexSlice[1:2]], pd.DataFrame), pd.DataFrame)
24042411
check(

0 commit comments

Comments
 (0)