Skip to content
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

STYLE: use types_or in pre-commit #38457

Merged
merged 4 commits into from
Dec 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
minimum_pre_commit_version: '2.9.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this 2.9.2, as the release note mentions

Fix default value for types_or so symlink and directory can be matched

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

repos:
- repo: https://github.com/python/black
rev: 20.8b1
Expand All @@ -24,7 +25,7 @@ repos:
name: isort (python)
- id: isort
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two isort hooks can be combined into one

Suggested change
- id: isort
- id: isort
types: [text]
types_or: [python, cython]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @MarcoGorelli for the explanation.

name: isort (cython)
types: [cython]
types_or: [python, cython]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
Expand All @@ -35,25 +36,25 @@ repos:
hooks:
- id: rst-backticks
- id: rst-directive-colons
types: [text]
types_or: [text]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
- id: rst-inline-touching-normal
types: [text]
types_or: [text]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
- 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)$
types_or: [file, non-executable, plain-text, text, yaml]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
pass_filenames: false
additional_dependencies: [pyyaml]
- id: flake8-rst
name: flake8-rst
description: Run flake8 on code snippets in docstrings or RST files
language: python
entry: flake8-rst
types: [rst]
types_or: [rst]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
args: [--filename=*.rst]
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
- id: non-standard-imports
Expand All @@ -77,7 +78,7 @@ repos:
# 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]
types_or: [python]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
- id: non-standard-imports-in-tests
name: Check for non-standard imports in test suite
language: pygrep
Expand All @@ -90,46 +91,45 @@ repos:
# No direct imports from conftest
conftest\ import|
import\ conftest
types: [python]
files: ^pandas/tests/
types_or: [python]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
- 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]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
- 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]
rkc007 marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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)^
Expand Down