-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow \
to be both a regex escape character and a windows directory delimiter in ignore-paths
option
#5398
Comments
@Pierre-Sassoulas This is actually a tricky bug to resolve. #5201 normalises |
What if we "normalize" the regex only if the current OS is actually windows ? I don't like making OS specific code but this feel justified here. |
Hmm, then users on windows can't use the Could we add a line to the description of the setting and say that escaping is not allowed since |
Could we use |
The problem is actually in the validator: pathlib.PureWindowsPath('.*\\ignore\\.*').as_posix()
'.*/ignore/.*'
pathlib.PureWindowsPath('.*\ignore\.*').as_posix()
'.*/ignore/.*' For some reason there is no difference here. Even |
Wouldn't it be better to disallow the use of the escape character? How often are you actually using the escape character in a regex for paths anyway? In the regex used in the OP the escape character is unnecessary as |
You're right, and on top of that we can now raise a proper configuration parsing error if the regex contain a forbidden character so it's going to be relatively easy to warn users. The real fix still eludes me though. At least if we don't want to do any breaking changes. |
Not sure that is so easy. Warning on
I don't have a good solution as well sadly.. @zeloras With regards to your initial question: we have reached the conclusion that we are going to disallow In your case updating the settings file to include |
\
to be both a regex escape character and a windows directory delimiter in ignore-paths
option
a workaround is to use [tool.pylint.MASTER]
ignore-patterns = '.*\.pyi' |
I think any option that modifies or limits regex patterns (like replacing all From just looking at this issue, before reading the documentation, I though that I also think these names would be much clearer: When the string is not a regex pattern, it should be fine to normalize To work with windows paths, Pattern: It would also be useful to have more examples in the documentation, to avoid ambiguities such as whether basename includes the extension (https://docs.python.org/3/library/os.path.html#os.path.basename) or not (https://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FilenameUtils.html#getBaseName-java.lang.String- ), and whether
But that would also match |
If we are going to rename configuration options we might as well also consider using The code that tests this is fairly straightforward and I'm very open to reviewing a PR that "fixes" this or at least improves the current situation. I won't have much time to work on this myself sadly. |
I agree with @Zeckie that limiting regex's escaping functionality is not a good idea.
|
Bug description
Good day/morning/evening!
Today i've update pylint to version 2.12.1 and for now that version ignoring ignore-paths=./migrations/..py,
in my .pylintrc config. But in version 2.11.1 everything is working correct
Configuration
Command used
Pylint output
Expected behavior
Your code has been rated at 10.00/10
Pylint version
OS / Environment
Linux d507ea5a5499 5.14.17-301.fc35.x86_64 #1 SMP Mon Nov 8 13:57:43 UTC 2021 x86_64 GNU/Linux
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: