From 4b1cd5d0084e031d9ff57bc0f22183fcd4e566f3 Mon Sep 17 00:00:00 2001 From: Rahul Chauhan Date: Sun, 13 Dec 2020 17:46:27 -0600 Subject: [PATCH 1/3] Changed types to types_or for pre-commit --- .pre-commit-config.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 717334bfe1299..5313684dd8e5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +minimum_pre_commit_version: '2.9.0' repos: - repo: https://github.com/python/black rev: 20.8b1 @@ -24,7 +25,7 @@ repos: name: isort (python) - id: isort name: isort (cython) - types: [cython] + types_or: [python, cython] - repo: https://github.com/asottile/pyupgrade rev: v2.7.4 hooks: @@ -35,9 +36,9 @@ repos: hooks: - id: rst-backticks - id: rst-directive-colons - types: [text] + types_or: [text] - id: rst-inline-touching-normal - types: [text] + types_or: [text] - repo: local hooks: - id: pip_to_conda @@ -45,7 +46,7 @@ repos: description: This hook checks if the conda environment.yml and requirements-dev.txt are equal language: python entry: python scripts/generate_pip_deps_from_conda.py - files: ^(environment.yml|requirements-dev.txt)$ + types_or: [file, non-executable, plain-text, text, yaml] pass_filenames: false additional_dependencies: [pyyaml] - id: flake8-rst @@ -53,7 +54,7 @@ repos: description: Run flake8 on code snippets in docstrings or RST files language: python entry: flake8-rst - types: [rst] + types_or: [rst] args: [--filename=*.rst] additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9] - id: non-standard-imports @@ -77,7 +78,7 @@ repos: # Check for imports from np.random. instead of `from numpy import random` or `from numpy.random import ` from\ numpy\ import\ random| from\ numpy.random\ import - types: [python] + types_or: [python] - id: non-standard-imports-in-tests name: Check for non-standard imports in test suite language: pygrep @@ -90,46 +91,45 @@ repos: # No direct imports from conftest conftest\ import| import\ conftest - types: [python] - files: ^pandas/tests/ + types_or: [python] - id: incorrect-code-directives name: Check for incorrect code block or IPython directives language: pygrep entry: (\.\. code-block ::|\.\. ipython ::) - files: \.(py|pyx|rst)$ + types_or: [file, non-executable, cython, text, yaml, python, rst] - id: unwanted-patterns-strings-to-concatenate name: Check for use of not concatenated strings language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate" - files: \.(py|pyx|pxd|pxi)$ + types_or: [file, non-executable, cython, text, yaml, python] - id: unwanted-patterns-strings-with-wrong-placed-whitespace name: Check for strings with wrong placed spaces language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace" - files: \.(py|pyx|pxd|pxi)$ + types_or: [file, non-executable, cython, text, yaml, python] - id: unwanted-patterns-private-import-across-module name: Check for import of private attributes across modules language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module" - types: [python] + types_or: [python] exclude: ^(asv_bench|pandas/tests|doc)/ - id: unwanted-patterns-private-function-across-module name: Check for use of private functions across modules language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module" - types: [python] + types_or: [python] exclude: ^(asv_bench|pandas/tests|doc)/ - id: inconsistent-namespace-usage name: 'Check for inconsistent use of pandas namespace in tests' entry: python scripts/check_for_inconsistent_pandas_namespace.py language: python - types: [python] + types_or: [python] files: ^pandas/tests/ - id: FrameOrSeriesUnion name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias entry: Union\[.*(Series.*DataFrame|DataFrame.*Series).*\] language: pygrep - types: [python] + types_or: [python] exclude: ^pandas/_typing\.py$ - id: type-not-class name: Check for use of foo.__class__ instead of type(foo) @@ -143,12 +143,12 @@ repos: \#\ type:\ (?!ignore)| \#\ type:\s?ignore(?!\[) language: pygrep - types: [python] + types_or: [python] - id: no-os-remove name: Check code for instances of os.remove entry: os\.remove language: pygrep - types: [python] + types_or: [python] files: ^pandas/tests/ exclude: | (?x)^ From 12908de5e84f5d973a942c2c2c8c358b959f357f Mon Sep 17 00:00:00 2001 From: Rahul Chauhan Date: Mon, 14 Dec 2020 12:28:28 -0600 Subject: [PATCH 2/3] Fixed types_or --- .pre-commit-config.yaml | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5313684dd8e5f..7a71ce9cc86b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,9 +22,7 @@ repos: rev: 5.6.4 hooks: - id: isort - name: isort (python) - - id: isort - name: isort (cython) + types: [text] types_or: [python, cython] - repo: https://github.com/asottile/pyupgrade rev: v2.7.4 @@ -36,9 +34,9 @@ repos: hooks: - id: rst-backticks - id: rst-directive-colons - types_or: [text] + types: [text] - id: rst-inline-touching-normal - types_or: [text] + types: [text] - repo: local hooks: - id: pip_to_conda @@ -46,7 +44,7 @@ repos: description: This hook checks if the conda environment.yml and requirements-dev.txt are equal language: python entry: python scripts/generate_pip_deps_from_conda.py - types_or: [file, non-executable, plain-text, text, yaml] + files: ^(environment.yml|requirements-dev.txt)$ pass_filenames: false additional_dependencies: [pyyaml] - id: flake8-rst @@ -54,7 +52,7 @@ repos: description: Run flake8 on code snippets in docstrings or RST files language: python entry: flake8-rst - types_or: [rst] + types: [rst] args: [--filename=*.rst] additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9] - id: non-standard-imports @@ -78,7 +76,7 @@ repos: # Check for imports from np.random. instead of `from numpy import random` or `from numpy.random import ` from\ numpy\ import\ random| from\ numpy.random\ import - types_or: [python] + types: [python] - id: non-standard-imports-in-tests name: Check for non-standard imports in test suite language: pygrep @@ -91,45 +89,46 @@ repos: # No direct imports from conftest conftest\ import| import\ conftest - types_or: [python] + types: [python] + files: ^pandas/tests/ - id: incorrect-code-directives name: Check for incorrect code block or IPython directives language: pygrep entry: (\.\. code-block ::|\.\. ipython ::) - types_or: [file, non-executable, cython, text, yaml, python, rst] + types_or: [python, cython, rst] - id: unwanted-patterns-strings-to-concatenate name: Check for use of not concatenated strings language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate" - types_or: [file, non-executable, cython, text, yaml, python] + types_or: [python, file, executable, text] - id: unwanted-patterns-strings-with-wrong-placed-whitespace name: Check for strings with wrong placed spaces language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace" - types_or: [file, non-executable, cython, text, yaml, python] + types_or: [python, file, executable, text] - id: unwanted-patterns-private-import-across-module name: Check for import of private attributes across modules language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module" - types_or: [python] + types: [python] exclude: ^(asv_bench|pandas/tests|doc)/ - id: unwanted-patterns-private-function-across-module name: Check for use of private functions across modules language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module" - types_or: [python] + types: [python] exclude: ^(asv_bench|pandas/tests|doc)/ - id: inconsistent-namespace-usage name: 'Check for inconsistent use of pandas namespace in tests' entry: python scripts/check_for_inconsistent_pandas_namespace.py language: python - types_or: [python] + types: [python] files: ^pandas/tests/ - id: FrameOrSeriesUnion name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias entry: Union\[.*(Series.*DataFrame|DataFrame.*Series).*\] language: pygrep - types_or: [python] + types: [python] exclude: ^pandas/_typing\.py$ - id: type-not-class name: Check for use of foo.__class__ instead of type(foo) @@ -143,12 +142,12 @@ repos: \#\ type:\ (?!ignore)| \#\ type:\s?ignore(?!\[) language: pygrep - types_or: [python] + types: [python] - id: no-os-remove name: Check code for instances of os.remove entry: os\.remove language: pygrep - types_or: [python] + types: [python] files: ^pandas/tests/ exclude: | (?x)^ From 14995bfc9e47ca8632ea2feb8f6ffd1310576953 Mon Sep 17 00:00:00 2001 From: Rahul Chauhan Date: Mon, 14 Dec 2020 13:04:21 -0600 Subject: [PATCH 3/3] fixed types and added minimum requirement --- .pre-commit-config.yaml | 8 ++++---- environment.yml | 2 +- requirements-dev.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a71ce9cc86b9..e4ea29aef2736 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -minimum_pre_commit_version: '2.9.0' +minimum_pre_commit_version: '2.9.2' repos: - repo: https://github.com/python/black rev: 20.8b1 @@ -22,7 +22,7 @@ repos: rev: 5.6.4 hooks: - id: isort - types: [text] + types: [text] # overwrite upstream `types: [python]` types_or: [python, cython] - repo: https://github.com/asottile/pyupgrade rev: v2.7.4 @@ -100,12 +100,12 @@ repos: name: Check for use of not concatenated strings language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate" - types_or: [python, file, executable, text] + types_or: [python, cython] - id: unwanted-patterns-strings-with-wrong-placed-whitespace name: Check for strings with wrong placed spaces language: python entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace" - types_or: [python, file, executable, text] + types_or: [python, cython] - id: unwanted-patterns-private-import-across-module name: Check for import of private attributes across modules language: python diff --git a/environment.yml b/environment.yml index b99b856187fb6..600a20b153ed3 100644 --- a/environment.yml +++ b/environment.yml @@ -24,7 +24,7 @@ dependencies: - flake8-comprehensions>=3.1.0 # used by flake8, linting of unnecessary comprehensions - isort>=5.2.1 # check that imports are in the right order - mypy=0.782 - - pre-commit + - pre-commit>=2.9.2 - pycodestyle # used by flake8 - pyupgrade diff --git a/requirements-dev.txt b/requirements-dev.txt index 17ca6b8401501..d45e87b1785b0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,7 +12,7 @@ flake8 flake8-comprehensions>=3.1.0 isort>=5.2.1 mypy==0.782 -pre-commit +pre-commit>=2.9.2 pycodestyle pyupgrade gitpython