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

add warning for regular expression with [/\] #2043

Closed
asottile opened this issue Sep 8, 2021 · 3 comments
Closed

add warning for regular expression with [/\] #2043

asottile opened this issue Sep 8, 2021 · 3 comments

Comments

@asottile
Copy link
Member

@asottile asottile commented Sep 8, 2021

pre-commit normalizes slashes to forward slashes since 2.5.0 (and further back to 1.19.0 for per-hook configuration)

there's already a similar warning for /* so this should be a fairly beginner-friendly changeset

@dogukanteber
Copy link

@dogukanteber dogukanteber commented Sep 14, 2021

Can you open up the issue a little more, please? I'd like to fix this issue but I could not understand the problem exactly.

@asottile
Copy link
Member Author

@asottile asottile commented Sep 14, 2021

right now, one may write something like:

    files: ^somedir[/\].*\.py$
    # or
    exclude: ^somedir[\/]otherdir[\/].*\.py$

expecting that they need to match both posix paths somedir/foo/bar.py and windows paths somedir\foo\bar.py -- however this is unnecessary because pre-commit normalizes all slashes to forward slashes

there's a similar regular expression warning for doing something like files: whatever/*.py where someone assumes that it is a glob and not a regex

radek-sprta added a commit to radek-sprta/pre-commit that referenced this issue Sep 17, 2021
asottile added a commit to radek-sprta/pre-commit that referenced this issue Sep 22, 2021
asottile added a commit that referenced this issue Sep 22, 2021
Add warning for regular expression with [\/] (#2043)
@asottile
Copy link
Member Author

@asottile asottile commented Oct 2, 2021

via #2053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants