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

doesn't respect ignore-pattern in pyproject.toml #169

Closed
DetachHead opened this issue Aug 23, 2022 · 21 comments
Closed

doesn't respect ignore-pattern in pyproject.toml #169

DetachHead opened this issue Aug 23, 2022 · 21 comments
Assignees
Labels
triage-needed Issue is not triaged.

Comments

@DetachHead
Copy link

[tool.pylint.MASTER]
ignore-patterns = '.*\.pyi'

image

@github-actions github-actions bot added the triage-needed Issue is not triaged. label Aug 23, 2022
@karthiknadig
Copy link
Member

@DanielNoord is there a way to know where the settings are loaded from? Debugging through the pylint code it seems to find the pyproject.toml but it is not using ignore-patterns for some reason, with --from-stdin

@DanielNoord
Copy link

With --verbose pylint prints some info about the configuration file being used to stdout. If that doesn't provide the information necessary some print statements in the _config_initialization function defined in pylint/config/config_initialization.py should definitely tell you what is being loaded.

@karthiknadig
Copy link
Member

karthiknadig commented Aug 31, 2022

Looks like it does pick up the pyproject.toml:
image

These are the arguments:
image

As far as I can tell this might be a bug with pylint check via stdin. The _is_ignored_file check does not happen in the from_stdin path.

@DanielNoord
Copy link

@DetachHead which version of pylint are you using? We recently (tried to) fix some issues with ignoring files on stdin. Perhaps we already fixed this, or we actually regressed here.

@karthiknadig
Copy link
Member

@DetachHead the logs from Output > pylint panel should have details on which version was loaded:
image

@DetachHead
Copy link
Author

pylint 2.14.5
astroid 2.11.7
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]

@DanielNoord
Copy link

Could you try 2.15.x?

@DetachHead
Copy link
Author

ok i have no clue what's going on here. the plugin is somehow using version 2.14.5 even though it's running from the exact same venv where i updated it to 2.15.0:

>poetry show -v
Using virtualenv: C:\Users\amogus\AppData\Local\pypoetry\Cache\virtualenvs\project-n2-MipS8-py3.10
>pylint --version
pylint 2.15.0
astroid 2.12.5
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]

but on the output tab:

C:\Users\amogus\AppData\Local\pypoetry\Cache\virtualenvs\project-n2-MipS8-py3.10\Scripts\python.exe -m pylint --version
CWD Linter: c:\Users\amogus\IdeaProjects\project

pylint 2.14.5
astroid 2.11.7
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]


Version info for linter running for c:\Users\amogus\IdeaProjects\project:
pylint 2.14.5
astroid 2.11.7
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]

@karthiknadig
Copy link
Member

@DetachHead It is loading from the bundle. Can you set the pylint.impoertStrategy setting to fromEnvironment?

@DetachHead
Copy link
Author

@karthiknadig thanks. now it's using the correct version (2.15.0) but it's still showing errors in .pyi files. let me know if there's any more info i can provide

@DanielNoord
Copy link

Sorry @DetachHead, should have recognised this. This is a "duplicate" of pylint-dev/pylint#5398.

We're compromising here and haven't found a good solution to fix this (other than just switching to glob patterns and making a breaking change).
Any good suggestions are much appreciated!

@karthiknadig This is a pylint issue and can be closed in this repository.

@DetachHead
Copy link
Author

DetachHead commented Sep 1, 2022

@DanielNoord @karthiknadig i don't think this is the same issue. i removed the \ from my ignore pattern and the issue persists. can this issue be re-opened?

[tool.pylint.MASTER]
ignore-patterns = '.*pyi'

@karthiknadig
Copy link
Member

The ignore_patterns check is only used when pylint is running over a directory, not when it is running on a single file whose contents are sent over stdin:
https://github.com/PyCQA/pylint/blob/a2c57ec06070b6d2485082e3a131a087f8d6d921/pylint/lint/pylinter.py#L603-L608

This could be solved by adding a ignore patterns check in this block:
https://github.com/PyCQA/pylint/blob/a2c57ec06070b6d2485082e3a131a087f8d6d921/pylint/lint/pylinter.py#L662-L666

1 similar comment
@karthiknadig
Copy link
Member

The ignore_patterns check is only used when pylint is running over a directory, not when it is running on a single file whose contents are sent over stdin:
https://github.com/PyCQA/pylint/blob/a2c57ec06070b6d2485082e3a131a087f8d6d921/pylint/lint/pylinter.py#L603-L608

This could be solved by adding a ignore patterns check in this block:
https://github.com/PyCQA/pylint/blob/a2c57ec06070b6d2485082e3a131a087f8d6d921/pylint/lint/pylinter.py#L662-L666

@DetachHead
Copy link
Author

looks like there's already a PR for this pylint-dev/pylint#7220

@DanielNoord
Copy link

Sorry for the confusion. That does indeed seem to be the issue. I'll take a look at getting that PR merged today!

@DanielNoord
Copy link

DanielNoord commented Sep 4, 2022

The PR has been merged and should be available in the next patch release. I expect that release to come somewhere next week!

Edit: Note that the issue with using \. still persists.

@DetachHead
Copy link
Author

DetachHead commented Sep 5, 2022

thanks! interestingly, my ignore pattern with the \ in it seems to work now as well. maybe it's because my pylint config is in pyproject.toml instead of .pylintrc?

@DanielNoord
Copy link

thanks! interestingly, my ignore pattern with the \ in it seems to work now as well. maybe it's because my pylint config is in pyproject.toml instead of .pylintrc?

Thanks for getting back to this in the other issues in our repository! 😄

@justOleh
Copy link

justOleh commented Feb 14, 2023

Hello. Could you please also check if this is fixed for using ignore = ["some_fille.py"]?
Because I'm having the same behaivour.

@justOleh
Copy link

it's working. problem was in "some_file.py", I was using relative path "folder/some_file.py" instead of "some_file.py".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

4 participants