From 42afa1ac44678f68fc87bf795c9c3b1c08c80fcb Mon Sep 17 00:00:00 2001 From: Rushabh Vasani Date: Wed, 27 Nov 2019 21:39:11 +0530 Subject: [PATCH] Fix mypy error in pandas/tests.indexes.test_base.py (#29188) --- pandas/tests/indexes/test_base.py | 34 +++++++++++++++---------------- setup.cfg | 3 --- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/pandas/tests/indexes/test_base.py b/pandas/tests/indexes/test_base.py index 2eaee82d7b3df1..9afda7b6461a25 100644 --- a/pandas/tests/indexes/test_base.py +++ b/pandas/tests/indexes/test_base.py @@ -507,7 +507,7 @@ def test_constructor_dtypes_timedelta(self, attr, klass): result = klass(list(values), dtype=dtype) tm.assert_index_equal(result, index) - @pytest.mark.parametrize("value", [[], iter([]), (x for x in [])]) + @pytest.mark.parametrize("value", [[], iter([]), (_ for _ in [])]) @pytest.mark.parametrize( "klass", [ @@ -530,7 +530,7 @@ def test_constructor_empty(self, value, klass): [ (PeriodIndex([], freq="B"), PeriodIndex), (PeriodIndex(iter([]), freq="B"), PeriodIndex), - (PeriodIndex((x for x in []), freq="B"), PeriodIndex), + (PeriodIndex((_ for _ in []), freq="B"), PeriodIndex), (RangeIndex(step=1), pd.RangeIndex), (MultiIndex(levels=[[1, 2], ["blue", "red"]], codes=[[], []]), MultiIndex), ], @@ -1726,22 +1726,22 @@ def test_slice_locs_na_raises(self): "in_slice,expected", [ (pd.IndexSlice[::-1], "yxdcb"), - (pd.IndexSlice["b":"y":-1], ""), - (pd.IndexSlice["b"::-1], "b"), - (pd.IndexSlice[:"b":-1], "yxdcb"), - (pd.IndexSlice[:"y":-1], "y"), - (pd.IndexSlice["y"::-1], "yxdcb"), - (pd.IndexSlice["y"::-4], "yb"), + (pd.IndexSlice["b":"y":-1], ""), # type: ignore + (pd.IndexSlice["b"::-1], "b"), # type: ignore + (pd.IndexSlice[:"b":-1], "yxdcb"), # type: ignore + (pd.IndexSlice[:"y":-1], "y"), # type: ignore + (pd.IndexSlice["y"::-1], "yxdcb"), # type: ignore + (pd.IndexSlice["y"::-4], "yb"), # type: ignore # absent labels - (pd.IndexSlice[:"a":-1], "yxdcb"), - (pd.IndexSlice[:"a":-2], "ydb"), - (pd.IndexSlice["z"::-1], "yxdcb"), - (pd.IndexSlice["z"::-3], "yc"), - (pd.IndexSlice["m"::-1], "dcb"), - (pd.IndexSlice[:"m":-1], "yx"), - (pd.IndexSlice["a":"a":-1], ""), - (pd.IndexSlice["z":"z":-1], ""), - (pd.IndexSlice["m":"m":-1], ""), + (pd.IndexSlice[:"a":-1], "yxdcb"), # type: ignore + (pd.IndexSlice[:"a":-2], "ydb"), # type: ignore + (pd.IndexSlice["z"::-1], "yxdcb"), # type: ignore + (pd.IndexSlice["z"::-3], "yc"), # type: ignore + (pd.IndexSlice["m"::-1], "dcb"), # type: ignore + (pd.IndexSlice[:"m":-1], "yx"), # type: ignore + (pd.IndexSlice["a":"a":-1], ""), # type: ignore + (pd.IndexSlice["z":"z":-1], ""), # type: ignore + (pd.IndexSlice["m":"m":-1], ""), # type: ignore ], ) def test_slice_locs_negative_step(self, in_slice, expected): diff --git a/setup.cfg b/setup.cfg index 46e6b88f8018aa..fa8b61a214cab2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -148,9 +148,6 @@ ignore_errors=True [mypy-pandas.tests.indexes.datetimes.test_tools] ignore_errors=True -[mypy-pandas.tests.indexes.test_base] -ignore_errors=True - [mypy-pandas.tests.scalar.period.test_period] ignore_errors=True