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 option to allow linting over all files #4217

Closed
wants to merge 1 commit into from

Conversation

tiagohonorato
Copy link
Contributor

Steps

  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

A new flag --lint-all=<yn> was added to enable linting over all files in and under a directory. By default, it will not alter pylint current behavior to process only traditional and namespace packages.

I have implemented some tests, but I feel that maybe it is worth going a bit further by, for example, checking how many files were expected to be checked and comparing with the number of files that were actually checked.

Signed-off-by: Tiago Honorato tiagohonorato1@gmail.com

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

#352

A new flag was added to enable linting over all files in and under a
directory. By default, it will not alter pylint current behavior to
process only traditional and namespace packages.

Signed-off-by: Tiago Honorato <tiagohonorato1@gmail.com>
@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.429% when pulling 5742f4c on tiagohonorato:lint_all_files into 0f1245c on PyCQA:master.

@Pierre-Sassoulas
Copy link
Member

I think this is addressing the highest voted and oldest still opened issue in pylint : #352, so this is much appreciated. We'll want this to be the default behavior and not an option because it feels natural for pylint to work like this. But we're going to need a lot more automated tests to make sure it's working, see in particular @AWhetter comment here: #352 (comment)

@tiagohonorato
Copy link
Contributor Author

Hi @Pierre-Sassoulas, I think we all would appreciate this feature, so happy to help here!

I totally agree with you on that linting all files definitely feels more natural. I decided to implement as an option just as a starting point since I was following the general idea and guidelines from #352, specially this comment from @PCManticore.

I recall reading the comment you mentioned, I will take a closer look and we can go from there.

@Pierre-Sassoulas
Copy link
Member

Ho yeah, let's keep the flag to deactivate it if needed, that's safer actually.

@tiagohonorato
Copy link
Contributor Author

@Pierre-Sassoulas, after looking a bit further, as we don't have any tests checking expand_modules, I think this might be a good place to start to make sure we have the desired behavior after the modifications. I will try to add some tests in the next few days.

@Pierre-Sassoulas
Copy link
Member

I added some tests for expand_modules in #4283, I think this is just the beginning but everything seems to happen here and I have a feeling things can be simplified. Please let me know what you think :)

@tiagohonorato
Copy link
Contributor Author

I added some tests for expand_modules in #4283, I think this is just the beginning but everything seems to happen here and I have a feeling things can be simplified. Please let me know what you think :)

Hi @Pierre-Sassoulas, thank you for helping here! I will rebase and take a closer look, but from what I could already notice, I really liked your approach to the unittest. I was having a lot of trouble to come up with something clean!

@DanielNoord
Copy link
Collaborator

@Pierre-Sassoulas Is there anything I can do to help this forward? I think this might be one of the most requested features within pylint looking at the original issue.

@Pierre-Sassoulas
Copy link
Member

Hey @DanielNoord you're right this is one of the most wanted feature, for good reasons. I think it's safe to say this MR is not moving right now, so if you want to build on it or even to do you own fix from scratch that would be very much appreciated (You can start by checking expand_modules).

@DanielNoord
Copy link
Collaborator

The general idea of this change seems fine, but I'm worried about this comment:
#352 (comment)
Does this PR consider the problems identified there enough?

@Pierre-Sassoulas
Copy link
Member

I don't think it was considered here and this is making everyone afraid of fixing this issue. But do we have to consider it to fix the issue ? Right now if you want to lint all files in a directory you can gives the file one by one (pre-commit does that) . Maybe there are unconsistencies if you do that instead of giving a directory containing the file but this is another issue imo.

@DanielNoord
Copy link
Collaborator

I was looking at #2967 as well, as they all seem related:
"How to treat the to-be-linted input variable".
Some of the code that handles this in astroid is part of the original commit 15 years ago. I am not sure but I feel like we might want to handle namespaces correctly before doing this as that will probably also include changes to how we handle the input.

@Pierre-Sassoulas
Copy link
Member

Closing in favor of #5682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants