From 2ce5e55e5636dd4e0f5b1e905e5f80163f3c962f Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Wed, 23 Dec 2020 11:41:17 -0700 Subject: [PATCH 1/7] Add the check-no-pd-class hook --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4ea29aef2736..4c18d7716847a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -154,6 +154,11 @@ repos: pandas/tests/io/excel/test_writers\.py| pandas/tests/io/pytables/common\.py| pandas/tests/io/pytables/test_store\.py$ + - id: check-no-pd-class + name: check for pd class. + types: [python] + entry: pd.testing.assert_series_equal + language: pygrep - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: From 8d1b2279d8c5cc65a54980017bd7cd68f39e90be Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Wed, 23 Dec 2020 12:34:42 -0700 Subject: [PATCH 2/7] make check more generic --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c18d7716847a..bf8848f815546 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -157,7 +157,7 @@ repos: - id: check-no-pd-class name: check for pd class. types: [python] - entry: pd.testing.assert_series_equal + entry: pd.testing. language: pygrep - repo: https://github.com/asottile/yesqa rev: v1.2.2 From 77f143c16e905be5494a7f75d20cba574db46d77 Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Wed, 23 Dec 2020 12:50:40 -0700 Subject: [PATCH 3/7] change instance of pd.testing in test class --- pandas/tests/groupby/aggregate/test_aggregate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/groupby/aggregate/test_aggregate.py b/pandas/tests/groupby/aggregate/test_aggregate.py index 073918eda3deb..324745fe0eab2 100644 --- a/pandas/tests/groupby/aggregate/test_aggregate.py +++ b/pandas/tests/groupby/aggregate/test_aggregate.py @@ -1049,7 +1049,7 @@ def test_groupby_get_by_index(): df = DataFrame({"A": ["S", "W", "W"], "B": [1.0, 1.0, 2.0]}) res = df.groupby("A").agg({"B": lambda x: x.get(x.index[-1])}) expected = DataFrame({"A": ["S", "W"], "B": [1.0, 2.0]}).set_index("A") - pd.testing.assert_frame_equal(res, expected) + tm.assert_frame_equal(res, expected) @pytest.mark.parametrize( From 40298f85f087e8afc47af987374a624d9681348d Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Wed, 23 Dec 2020 15:41:13 -0700 Subject: [PATCH 4/7] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf8848f815546..0da89b360a836 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -157,7 +157,7 @@ repos: - id: check-no-pd-class name: check for pd class. types: [python] - entry: pd.testing. + entry: pd.testing\. language: pygrep - repo: https://github.com/asottile/yesqa rev: v1.2.2 From 7c6c4bfab58f429fb5e63df9ebfe19c4a553a5ca Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Wed, 23 Dec 2020 15:44:39 -0700 Subject: [PATCH 5/7] Add wildcard to entry in pre-commit config file --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0da89b360a836..014cdc1009212 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -157,7 +157,7 @@ repos: - id: check-no-pd-class name: check for pd class. types: [python] - entry: pd.testing\. + entry: pd.testing.\. language: pygrep - repo: https://github.com/asottile/yesqa rev: v1.2.2 From 733b1ef40d512ba4c8a554b3611de385627f572c Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Thu, 24 Dec 2020 11:34:06 -0700 Subject: [PATCH 6/7] Add check to import test check --- .pre-commit-config.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 014cdc1009212..ad4f218009aef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -89,6 +89,9 @@ repos: # No direct imports from conftest conftest\ import| import\ conftest + + # Check for use of pandas.testing instead of tm + pd.testing.\ types: [python] files: ^pandas/tests/ - id: incorrect-code-directives @@ -154,11 +157,6 @@ repos: pandas/tests/io/excel/test_writers\.py| pandas/tests/io/pytables/common\.py| pandas/tests/io/pytables/test_store\.py$ - - id: check-no-pd-class - name: check for pd class. - types: [python] - entry: pd.testing.\. - language: pygrep - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: From 8081304ea4a309e0ed1f7e85f69c08daedaa3771 Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Sat, 26 Dec 2020 08:01:28 -0700 Subject: [PATCH 7/7] Update .pre-commit-config.yaml Co-authored-by: Marco Gorelli --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad4f218009aef..1e818e4ef2306 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -91,7 +91,7 @@ repos: import\ conftest # Check for use of pandas.testing instead of tm - pd.testing.\ + pd\.testing\. types: [python] files: ^pandas/tests/ - id: incorrect-code-directives