From 4e21a311794196670835fd9a0151ae13c5f57a9a Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Mon, 2 Dec 2024 17:36:25 -0500 Subject: [PATCH] adjust test for slice due to typeshed changes (#1067) * adjust test for slice due to typeshed changes * comment out the previous test --- tests/test_frame.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_frame.py b/tests/test_frame.py index 1dd92515..bffc8ef6 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -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(