Skip to content

CI consistently put | at start of line in pygrep hooks #39301

Closed
@MarcoGorelli

Description

@MarcoGorelli

Currently, the pygrep hooks have the "or" | symbol at the end of the line, which makes diffs longer than necessary and can cause bugs. It would be better to put that symbol at the beginning of the line.

For example, instead of

    -   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

it should be

    -   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

There's even an | symbol missing in the non-standard-imports-in-tests, which should be fixed (having the symbol at the beginning of the line would probably have made this easier to spot)

The file that needs changing is .pre-commit-config.yaml

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions