Skip to content

Reorder pre-commit-config and normalize id names #40277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 112 additions & 113 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
minimum_pre_commit_version: 2.9.2
exclude: ^LICENSES/|\.(html|csv|svg)$
repos:
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.2.1
hooks:
- id: absolufy-imports
files: ^pandas/
- repo: https://github.com/python/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
types_or: [python, rst, markdown]
files: ^pandas/
exclude: ^pandas/tests/
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: end-of-file-fixer
exclude: \.txt$
- id: trailing-whitespace
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
Expand All @@ -23,6 +41,10 @@ repos:
rev: 5.7.0
hooks:
- id: isort
- repo: https://github.com/MarcoGorelli/no-string-hints
rev: v0.1.7
hooks:
- id: no-string-hints
- repo: https://github.com/asottile/pyupgrade
rev: v2.10.0
hooks:
Expand All @@ -38,16 +60,12 @@ repos:
- id: rst-inline-touching-normal
types: [text] # overwrite types: [rst]
types_or: [python, rst]
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
hooks:
- id: yesqa
- repo: local
hooks:
- id: pip_to_conda
name: Generate pip dependency from conda
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)$
pass_filenames: false
additional_dependencies: [pyyaml]
- id: flake8-rst
name: flake8-rst
description: Run flake8 on code snippets in docstrings or RST files
Expand All @@ -56,6 +74,40 @@ repos:
types: [rst]
args: [--filename=*.rst]
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
- id: frame-or-series-union
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
language: pygrep
types: [python]
exclude: ^pandas/_typing\.py$
- 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]
files: ^pandas/tests/frame/
- id: incorrect-code-directives
name: Check for incorrect code block or IPython directives
language: pygrep
entry: (\.\. code-block ::|\.\. ipython ::)
types_or: [python, cython, rst]
- id: no-os-remove
name: Check code for instances of os.remove
entry: os\.remove
language: pygrep
types: [python]
files: ^pandas/tests/
exclude: |
(?x)^
pandas/tests/io/excel/test_writers\.py
|pandas/tests/io/pytables/common\.py
|pandas/tests/io/pytables/test_store\.py$
- id: no-pandas-api-types
name: Check code for instances of pd.api.types
entry: (pd|pandas)\.api\.types\.
language: pygrep
types: [python]
files: ^pandas/tests/
- id: non-standard-imports
name: Check for non-standard imports
language: pygrep
Expand All @@ -67,17 +119,6 @@ repos:

# Check for imports from collections.abc instead of `from collections import abc`
|from\ collections\.abc\ import

- id: non-standard-numpy.random-related-imports
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
language: pygrep
exclude: pandas/_testing.py
entry: |
(?x)
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
from\ numpy\ import\ random
|from\ numpy.random\ import
types: [python]
- id: non-standard-imports-in-tests
name: Check for non-standard imports in test suite
language: pygrep
Expand All @@ -95,62 +136,79 @@ repos:
|pd\.testing\.
types: [python]
files: ^pandas/tests/
- id: incorrect-code-directives
name: Check for incorrect code block or IPython directives
- id: non-standard-numpy-random-related-imports
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
language: pygrep
exclude: pandas/_testing.py
entry: |
(?x)
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
from\ numpy\ import\ random
|from\ numpy.random\ import
types: [python]
- id: np-bool
name: Check for use of np.bool instead of np.bool_
entry: np\.bool[^_8]
language: pygrep
entry: (\.\. code-block ::|\.\. ipython ::)
types_or: [python, cython, rst]
- id: unwanted-patterns-strings-to-concatenate
name: Check for use of not concatenated strings
- id: np-object
name: Check for use of np.object instead of np.object_
entry: np\.object[^_8]
language: pygrep
types_or: [python, cython, rst]
- id: pip-to-conda
name: Generate pip dependency from conda
description: This hook checks if the conda environment.yml and requirements-dev.txt are equal
language: python
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
types_or: [python, cython]
- id: unwanted-patterns-strings-with-wrong-placed-whitespace
name: Check for strings with wrong placed spaces
entry: python scripts/generate_pip_deps_from_conda.py
files: ^(environment.yml|requirements-dev.txt)$
pass_filenames: false
additional_dependencies: [pyyaml]
- id: title-capitalization
name: Validate correct capitalization among titles in documentation
entry: python scripts/validate_rst_title_capitalization.py
language: python
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
types: [rst]
files: ^doc/source/(development|reference)/
- id: type-not-class
name: Check for use of foo.__class__ instead of type(foo)
entry: \.__class__
language: pygrep
types_or: [python, cython]
- id: unwanted-patterns-private-import-across-module
name: Check for import of private attributes across modules
- id: unwanted-patterns-bare-pytest-raises
name: Check for use of bare pytest raises
language: python
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
entry: python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
types: [python]
exclude: ^(asv_bench|pandas/tests|doc)/
files: ^pandas/tests/
exclude: ^pandas/tests/extension/
- 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]
exclude: ^(asv_bench|pandas/tests|doc)/
- id: unwanted-patterns-bare-pytest-raises
name: Check for use of bare pytest raises
- 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="bare_pytest_raises"
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
types: [python]
files: ^pandas/tests/
exclude: ^pandas/tests/extension/
- id: unwanted-patters-pytest-xfail
exclude: ^(asv_bench|pandas/tests|doc)/
- id: unwanted-patterns-pytest-xfail
name: Check for use of pytest.xfail
entry: pytest\.xfail
language: pygrep
types: [python]
files: ^pandas/tests/
- id: inconsistent-namespace-usage
name: 'Check for inconsistent use of pandas namespace in tests'
entry: python scripts/check_for_inconsistent_pandas_namespace.py
- id: unwanted-patterns-strings-to-concatenate
name: Check for use of not concatenated strings
language: python
types: [python]
files: ^pandas/tests/frame/
- id: FrameOrSeriesUnion
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
language: pygrep
types: [python]
exclude: ^pandas/_typing\.py$
- id: type-not-class
name: Check for use of foo.__class__ instead of type(foo)
entry: \.__class__
language: pygrep
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
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, cython]
- id: unwanted-typing
name: Check for outdated annotation syntax and missing error codes
Expand All @@ -160,62 +218,3 @@ repos:
|\#\ type:\s?ignore(?!\[)
language: pygrep
types: [python]
- id: np-bool
name: Check for use of np.bool instead of np.bool_
entry: np\.bool[^_8]
language: pygrep
types_or: [python, cython, rst]
- id: np-object
name: Check for use of np.object instead of np.object_
entry: np\.object[^_8]
language: pygrep
types_or: [python, cython, rst]
- id: no-os-remove
name: Check code for instances of os.remove
entry: os\.remove
language: pygrep
types: [python]
files: ^pandas/tests/
exclude: |
(?x)^
pandas/tests/io/excel/test_writers\.py
|pandas/tests/io/pytables/common\.py
|pandas/tests/io/pytables/test_store\.py$
- id: no-pandas-api-types
name: Check code for instances of pd.api.types
entry: (pd|pandas)\.api\.types\.
language: pygrep
types: [python]
files: ^pandas/tests/
- id: title-capitalization
name: Validate correct capitalization among titles in documentation
entry: python scripts/validate_rst_title_capitalization.py
language: python
types: [rst]
files: ^doc/source/(development|reference)/
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: end-of-file-fixer
exclude: \.txt$
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
types_or: [python, rst, markdown]
files: ^pandas/
exclude: ^pandas/tests/
- repo: https://github.com/MarcoGorelli/no-string-hints
rev: v0.1.7
hooks:
- id: no-string-hints
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.2.1
hooks:
- id: absolufy-imports
files: ^pandas/