From eccbcfb0dd727c976b4258a947647c97ab5935bb Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Mon, 19 Jul 2021 22:34:52 -0500 Subject: [PATCH 1/3] TYP: move mypy config to pyproject.toml --- ci/code_checks.sh | 2 +- .../development/contributing_codebase.rst | 2 +- pandas/tests/io/xml/test_xml.py | 2 +- pyproject.toml | 37 +++++++++++++ setup.cfg | 55 ------------------- 5 files changed, 40 insertions(+), 58 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 59548ecd3c710..217f23b28c123 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -166,7 +166,7 @@ if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then mypy --version MSG='Performing static analysis using mypy' ; echo $MSG - mypy pandas + mypy RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 721b1af126709..97b0f69d1d5a0 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -400,7 +400,7 @@ pandas uses `mypy `_ to statically analyze the code base a .. code-block:: shell - mypy pandas + mypy .. _contributing.ci: diff --git a/pandas/tests/io/xml/test_xml.py b/pandas/tests/io/xml/test_xml.py index 7e9a03c2a59a8..78924fb76edc1 100644 --- a/pandas/tests/io/xml/test_xml.py +++ b/pandas/tests/io/xml/test_xml.py @@ -682,7 +682,7 @@ def test_names_option_wrong_type(datapath, parser): with pytest.raises(TypeError, match=("is not a valid type for names")): read_xml( - filename, names="Col1, Col2, Col3", parser=parser # type: ignore[arg-type] + filename, names="Col1, Col2, Col3", parser=parser ) diff --git a/pyproject.toml b/pyproject.toml index 5deb92281475b..a2998050b8954 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,3 +67,40 @@ markers = [ "arm_slow: mark a test as slow for arm64 architecture", "arraymanager: mark a test to run with ArrayManager enabled", ] + +[tool.mypy] +files = "pandas" +platform = "linux-64" +namespace_packages = true +ignore_missing_imports = true +no_implicit_optional = true +check_untyped_defs = true +strict_equality = true +warn_redundant_casts = true +warn_unused_ignores = true +show_error_codes = true + +[[tool.mypy.overrides]] +module = [ + "pandas.tests.*", + "pandas._version", + "pandas.io.clipboard", +] +check_untyped_defs = false + +[[tool.mypy.overrides]] +module = [ + "pandas.tests.apply.test_series_apply", + "pandas.tests.arithmetic.conftest", + "pandas.tests.arrays.sparse.test_combine_concat", + "pandas.tests.dtypes.test_common", + "pandas.tests.frame.methods.test_to_records", + "pandas.tests.groupby.test_rank", + "pandas.tests.groupby.transform.test_transform", + "pandas.tests.indexes.interval.test_interval", + "pandas.tests.indexing.test_categorical", + "pandas.tests.io.excel.test_writers", + "pandas.tests.reductions.test_reductions", + "pandas.tests.test_expressions", +] +ignore_errors = true diff --git a/setup.cfg b/setup.cfg index 566248156cdc8..dca65be27ab77 100644 --- a/setup.cfg +++ b/setup.cfg @@ -205,58 +205,3 @@ force_grid_wrap = True force_sort_within_sections = True skip_glob = env, skip = pandas/__init__.py - -[mypy] -platform = linux-64 -ignore_missing_imports = True -no_implicit_optional = True -check_untyped_defs = True -strict_equality = True -warn_redundant_casts = True -warn_unused_ignores = True -show_error_codes = True - -[mypy-pandas.tests.*] -check_untyped_defs = False - -[mypy-pandas._version] -check_untyped_defs = False - -[mypy-pandas.io.clipboard] -check_untyped_defs = False - -[mypy-pandas.tests.apply.test_series_apply] -ignore_errors = True - -[mypy-pandas.tests.arithmetic.conftest] -ignore_errors = True - -[mypy-pandas.tests.arrays.sparse.test_combine_concat] -ignore_errors = True - -[mypy-pandas.tests.dtypes.test_common] -ignore_errors = True - -[mypy-pandas.tests.frame.methods.test_to_records] -ignore_errors = True - -[mypy-pandas.tests.groupby.test_rank] -ignore_errors = True - -[mypy-pandas.tests.groupby.transform.test_transform] -ignore_errors = True - -[mypy-pandas.tests.indexes.interval.test_interval] -ignore_errors = True - -[mypy-pandas.tests.indexing.test_categorical] -ignore_errors = True - -[mypy-pandas.tests.io.excel.test_writers] -ignore_errors = True - -[mypy-pandas.tests.reductions.test_reductions] -ignore_errors = True - -[mypy-pandas.tests.test_expressions] -ignore_errors = True From d64f1a3d933b020f51899622c3f0f77ab330b264 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Tue, 20 Jul 2021 07:57:07 -0500 Subject: [PATCH 2/3] add ignore back --- pandas/tests/io/xml/test_xml.py | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/tests/io/xml/test_xml.py b/pandas/tests/io/xml/test_xml.py index 78924fb76edc1..7e9a03c2a59a8 100644 --- a/pandas/tests/io/xml/test_xml.py +++ b/pandas/tests/io/xml/test_xml.py @@ -682,7 +682,7 @@ def test_names_option_wrong_type(datapath, parser): with pytest.raises(TypeError, match=("is not a valid type for names")): read_xml( - filename, names="Col1, Col2, Col3", parser=parser + filename, names="Col1, Col2, Col3", parser=parser # type: ignore[arg-type] ) diff --git a/pyproject.toml b/pyproject.toml index a2998050b8954..f083e919f7bb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,6 @@ markers = [ [tool.mypy] files = "pandas" platform = "linux-64" -namespace_packages = true ignore_missing_imports = true no_implicit_optional = true check_untyped_defs = true From 5dbb61ae6ad1a1fb103b3735b7a0db4c74e417d8 Mon Sep 17 00:00:00 2001 From: Fangchen Li Date: Tue, 20 Jul 2021 07:59:42 -0500 Subject: [PATCH 3/3] revert changes in mypy config --- ci/code_checks.sh | 2 +- doc/source/development/contributing_codebase.rst | 2 +- pyproject.toml | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 217f23b28c123..59548ecd3c710 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -166,7 +166,7 @@ if [[ -z "$CHECK" || "$CHECK" == "typing" ]]; then mypy --version MSG='Performing static analysis using mypy' ; echo $MSG - mypy + mypy pandas RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 97b0f69d1d5a0..721b1af126709 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -400,7 +400,7 @@ pandas uses `mypy `_ to statically analyze the code base a .. code-block:: shell - mypy + mypy pandas .. _contributing.ci: diff --git a/pyproject.toml b/pyproject.toml index f083e919f7bb6..e24704e24c5cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,6 @@ markers = [ ] [tool.mypy] -files = "pandas" platform = "linux-64" ignore_missing_imports = true no_implicit_optional = true