Skip to content

Commit

Permalink
adjust test for slice due to typeshed changes (#1067)
Browse files Browse the repository at this point in the history
* adjust test for slice due to typeshed changes

* comment out the previous test
  • Loading branch information
Dr-Irv authored Dec 2, 2024
1 parent 4529b51 commit 4e21a31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,14 @@ def test_indexslice_getitem():
.set_index(["x", "y"])
)
ind = pd.Index([2, 3])
check(assert_type(pd.IndexSlice[ind, :], tuple["pd.Index[int]", slice]), tuple)
# This next test is written this way to support both mypy 1.13 and newer
# versions of mypy and pyright that treat slice as a Generic due to
# a change in typeshed.
# Once pyright 1.1.390 and mypy 1.14 are released, the test can be
# reverted to the standard form.
# check(assert_type(pd.IndexSlice[ind, :], tuple["pd.Index[int]", slice]), tuple)
tmp: tuple[pd.Index[int], slice] = pd.IndexSlice[ind, :]
check(assert_type(tmp, tuple["pd.Index[int]", slice]), tuple)
check(assert_type(df.loc[pd.IndexSlice[ind, :]], pd.DataFrame), pd.DataFrame)
check(assert_type(df.loc[pd.IndexSlice[1:2]], pd.DataFrame), pd.DataFrame)
check(
Expand Down

0 comments on commit 4e21a31

Please sign in to comment.