From a19c844c354fb1d3d089233de1bafdecbdf869a2 Mon Sep 17 00:00:00 2001 From: Lukas Bentkamp Date: Sat, 12 Oct 2019 23:52:25 +0200 Subject: [PATCH 1/5] CLN: fix mypy errors in pandas/tests/extension/test_numpy.py #28926 --- pandas/tests/extension/base/ops.py | 9 +++++---- setup.cfg | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pandas/tests/extension/base/ops.py b/pandas/tests/extension/base/ops.py index e35464964f432..cee45943e0976 100644 --- a/pandas/tests/extension/base/ops.py +++ b/pandas/tests/extension/base/ops.py @@ -1,4 +1,5 @@ import operator +from typing import Type, Union import pytest @@ -61,10 +62,10 @@ class BaseArithmeticOpsTests(BaseOpsUtil): * divmod_exc = TypeError """ - series_scalar_exc = TypeError - frame_scalar_exc = TypeError - series_array_exc = TypeError - divmod_exc = TypeError + series_scalar_exc = TypeError # type: Union[Type[Exception], None] + frame_scalar_exc = TypeError # type: Union[Type[Exception], None] + series_array_exc = TypeError # type: Union[Type[Exception], None] + divmod_exc = TypeError # type: Union[Type[Exception], None] def test_arith_series_with_scalar(self, data, all_arithmetic_operators): # series & scalar diff --git a/setup.cfg b/setup.cfg index 9c841b76761f5..4b14089ea9a63 100644 --- a/setup.cfg +++ b/setup.cfg @@ -166,9 +166,6 @@ ignore_errors=True [mypy-pandas.tests.extension.json.test_json] ignore_errors=True -[mypy-pandas.tests.extension.test_numpy] -ignore_errors=True - [mypy-pandas.tests.extension.test_sparse] ignore_errors=True From 28b71205821a5786c9e69aa241f95282f0036724 Mon Sep 17 00:00:00 2001 From: Lukas Bentkamp Date: Sun, 13 Oct 2019 12:58:42 +0200 Subject: [PATCH 2/5] Applied suggestions, PR also fixes errors in test_sparse.py --- pandas/tests/extension/base/ops.py | 8 ++++---- setup.cfg | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pandas/tests/extension/base/ops.py b/pandas/tests/extension/base/ops.py index cee45943e0976..162a0e3b3058d 100644 --- a/pandas/tests/extension/base/ops.py +++ b/pandas/tests/extension/base/ops.py @@ -62,10 +62,10 @@ class BaseArithmeticOpsTests(BaseOpsUtil): * divmod_exc = TypeError """ - series_scalar_exc = TypeError # type: Union[Type[Exception], None] - frame_scalar_exc = TypeError # type: Union[Type[Exception], None] - series_array_exc = TypeError # type: Union[Type[Exception], None] - divmod_exc = TypeError # type: Union[Type[Exception], None] + series_scalar_exc = TypeError # type: Optional[Type[TypeError]] + frame_scalar_exc = TypeError # type: Optional[Type[TypeError]] + series_array_exc = TypeError # type: Optional[Type[TypeError]] + divmod_exc = TypeError # type: Optional[Type[TypeError]] def test_arith_series_with_scalar(self, data, all_arithmetic_operators): # series & scalar diff --git a/setup.cfg b/setup.cfg index 4b14089ea9a63..9af7215b1dc56 100644 --- a/setup.cfg +++ b/setup.cfg @@ -166,9 +166,6 @@ ignore_errors=True [mypy-pandas.tests.extension.json.test_json] ignore_errors=True -[mypy-pandas.tests.extension.test_sparse] -ignore_errors=True - [mypy-pandas.tests.frame.test_constructors] ignore_errors=True From 008fe48c8eae07dc9916aa003cdefec880e6d57b Mon Sep 17 00:00:00 2001 From: Lukas Bentkamp Date: Sun, 13 Oct 2019 13:09:24 +0200 Subject: [PATCH 3/5] Adjusted imports --- pandas/tests/extension/base/ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/base/ops.py b/pandas/tests/extension/base/ops.py index 162a0e3b3058d..e968962caf0b7 100644 --- a/pandas/tests/extension/base/ops.py +++ b/pandas/tests/extension/base/ops.py @@ -1,5 +1,5 @@ import operator -from typing import Type, Union +from typing import Optional, Type import pytest From 217adc84dc69045c566ec2c510ae11e1d531bbac Mon Sep 17 00:00:00 2001 From: Lukas Bentkamp Date: Tue, 15 Oct 2019 10:02:25 +0200 Subject: [PATCH 4/5] CLN: added type hint for mypy to test_coercion.py --- pandas/tests/indexing/test_coercion.py | 3 ++- setup.cfg | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index 05b58b0eca9b8..dd0d310616142 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -1,4 +1,5 @@ import itertools +from typing import Any, Dict, List import numpy as np import pytest @@ -928,7 +929,7 @@ class TestReplaceSeriesCoercion(CoercionBase): klasses = ["series"] method = "replace" - rep = {} + rep = {} # type: Dict[str, List[Any]] rep["object"] = ["a", "b"] rep["int64"] = [4, 5] rep["float64"] = [1.1, 2.2] diff --git a/setup.cfg b/setup.cfg index 9af7215b1dc56..a615d938de829 100644 --- a/setup.cfg +++ b/setup.cfg @@ -199,9 +199,6 @@ ignore_errors=True [mypy-pandas.tests.indexes.timedeltas.test_timedelta] ignore_errors=True -[mypy-pandas.tests.indexing.test_coercion] -ignore_errors=True - [mypy-pandas.tests.indexing.test_loc] ignore_errors=True From f43d1e2845ff9a0a39daea62caf57efbdf0f1a5c Mon Sep 17 00:00:00 2001 From: Lukas Bentkamp Date: Wed, 16 Oct 2019 19:37:49 +0200 Subject: [PATCH 5/5] Implementing requested change: List[Any] -> List --- pandas/tests/indexing/test_coercion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/indexing/test_coercion.py b/pandas/tests/indexing/test_coercion.py index dd0d310616142..4f38d7beb9c0b 100644 --- a/pandas/tests/indexing/test_coercion.py +++ b/pandas/tests/indexing/test_coercion.py @@ -1,5 +1,5 @@ import itertools -from typing import Any, Dict, List +from typing import Dict, List import numpy as np import pytest @@ -929,7 +929,7 @@ class TestReplaceSeriesCoercion(CoercionBase): klasses = ["series"] method = "replace" - rep = {} # type: Dict[str, List[Any]] + rep = {} # type: Dict[str, List] rep["object"] = ["a", "b"] rep["int64"] = [4, 5] rep["float64"] = [1.1, 2.2]