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 a way to ignore by full path, not basename #2279

Closed
whatisaphone opened this issue Jul 12, 2018 · 7 comments
Closed

Add a way to ignore by full path, not basename #2279

whatisaphone opened this issue Jul 12, 2018 · 7 comments
Labels
Enhancement ✨ Improvement to a component Invalid Not a bug, already exists or already fixed

Comments

@whatisaphone
Copy link

Background info:

I have adopted a rickety old Python codebase and I'm in the process of cleaning it up. I'm using a number of code quality tools including pylint, flake8, and mypy. My process for each checker has been to set up sane default rules, and an ignore list explicitly ignoring all files in the project. Then one by one I clean a file and remove the exclusion.

Unfortunately that won't work for pylint because according to the latest docs both ignore and ignore-patterns only look at base names, not full paths. My exclude list for flake8 looks something like this:

exclude =
    auth/models.py
    auth/views.py
    dashboard/models.py
    dashboard/views.py

I don't see any way in Pylint to ignore only e.g. auth/views.py, while enforcing rules in dashboard/views.py. Pylint is the only tool I couldn't manage to configure in a way that supports cleaning things up progressively.

I would like to use Pylint on this project. Is there a chance the options could be expanded to support this use case?

@PCManticore
Copy link
Contributor

Yes, definitely, sounds like a good enhancement.

@PCManticore PCManticore added the Enhancement ✨ Improvement to a component label Jul 16, 2018
@PCManticore PCManticore changed the title Ignoring by basename is not specific enough. Is there a way to ignore by full path (or full module name)? Add a way to ignore by full path, not basename Jul 16, 2018
@soullivaneuh
Copy link

soullivaneuh commented Oct 11, 2019

The best and simplest way is to provide a --ignore-path option and respect the .gitignore system which is the most popular.

Example:

pylint --ignore-path .gitignore

We can also make .gitignore or vcs ignore files usage to be the default. Indeed, ignored files do not need to be linted.

This technique is used by many tools. You can take a look with eslint or stylelint for example.

You may want to use a dedicated ignore parser for that. I found one: https://github.com/mherrmann/gitignore_parser

@Pierre-Sassoulas Pierre-Sassoulas added the Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning label Jun 30, 2022
@Pierre-Sassoulas
Copy link
Member

@matusvalo do you think we can close this one ?

@matusvalo
Copy link
Collaborator

I think we can close it. --ignore-paths can be used:

--ignore-paths=^auth/models.py$,^auth/views.py$,^dashboard/models.py$

It is not 100% due #5398 but should work.

@matusvalo matusvalo added Invalid Not a bug, already exists or already fixed and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning labels Jul 6, 2022
@matusvalo matusvalo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2022
@soullivaneuh
Copy link

@matusvalo @Pierre-Sassoulas the --ignore-paths option does not have the same behavior.

What about the .gitignore style solution?

@Pierre-Sassoulas
Copy link
Member

@soullivaneuh could you open a new enhancement issue for taking the .gitignore into account ?

@soullivaneuh
Copy link

@Pierre-Sassoulas sure! Please consider #7371.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

5 participants