Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Lint all files in a directory by expanding arguments #5682
Lint all files in a directory by expanding arguments #5682
Changes from 29 commits
e44977d
9b23124
20ad408
2aceafb
404bb9b
44f1919
b42df9c
3ebb1d7
6520a4e
8741104
91fe106
6623eb1
bc45736
8ae1438
756acc5
e83f9fc
ca13575
c9e571e
68529b5
b5e5bb6
6199d4e
59480dc
f47c9b8
03a0890
1de1999
a86cf14
3d96598
20dcce4
1aa4fdc
154f7d9
0864585
8bf62cb
5735618
ca79dae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to happen before in the initialization but should we make recursive true, if pylint is called without directory (
pylint --rc-file=...
), or with.
(pylint . --rc-file=...
) and if__init__.py
does not exists in the current directory ? I think the intent to use recursive is clear for those two as it would only work if there was an__init__.py
present. So we could fix it right now (before releasing pylint 3.0). On the other hand modifying behavior based on other argument than the one controlling the behavior feels wrong. @DanielNoord, thought ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
pylint --rc-file=...
should be allowed. It should either bepylint . --rc-file=...
or with another directory.We could discuss allowing
pylint --rc-file=...
if we add support for afiles
option inrc-file
, but runningpylint
without any clear intent on what directory to lint wouldn't be good imo. How would we display the help message then?I agree that
recursive=y
should be set when called with.
as directory. The same probably goes for missing__init__.py
. However, those would be breaking changes and I wonder how much depends on this currently not being supported. I'd be hesitant to change this in a minor version.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest does this I think it's a nice default value. It was asked here and has currently 12 upvotes
pylint --help
, orpylint -h
, which I think is the expectation for CLI tool.Β (alsopylint --long-help
because we're special π)I meant both
.
Β and no__init__.py
in the current directory at the same time. In this configuration the current result would be a fatal and nothing working so I guess it would not be a real breaking change (although there's probably someone somewhere who check for pylint exiting with a fatal instead of checking for an__init__.py
π ).You made me realize that in fact we can make recursive true when there is no
__init__.py
in any directory we lint and it does not matter if it's.
the argument that it was not working at all before is still true. But changing the recusrive option for.
Β would be a breaking change as pylint could be working before if there was an__init__.py
in the top level directory, but would start to lint new files unexpectedly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy
also allows this but only when you setfiles
in your config. I really think we shouldn't allow this without settingfiles
first.My expectation is that just running the command also gives a short help message. I know so many CLI tool that do this.
Edit: Let me rephrase, I know that
pytest
doesn't do this but it has done so for as long as I can remember I think. Changing the behaviour of runningpylint
without any arguments is a real breaking change which I would argue against. If we would supportfiles
andrecursive
people can just set those and then runpylint
without args if they want to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what happen when the tool can't work without providing arguments. For example
ls
orpwd
,pytest
orflake8
can run without args so they do.mv
Β orscp
can't, so they display the help (or something telling you how to display the help in the case of mv):Imo, pylint should work without any argument (like flake8). But I wonder why mypy do not though. Do you know the rational behind it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For 1, no, it should show the help like before, we did not reach a consensus on this with @DanielNoord and I'm going to create an issue to settle it by popular vote, once we merge this one. (By the way, what do you think of defaulting to "." ? :) )
For 2. yes exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for myself but perhaps helpful for others. I think for now this is the summary:
For
2.x
:When in
spam
without__init__.py
:pylint .
> Recursivepylint
> Exit without doing anything.pylint ../spam
> ??? (Recursive I guess)?When in
spam
with__init__.py
:pylint .
> not recursivepylint
> Exit without doing anything.pylint ../spam
> ??? (Not recursive I guess)?When in parent without
__init__.py
ofspam
without__init__.py
:pylint .
> Recursive, findsspam
pylint spam
> Recursivepylint
> Exit without doing anything.pylint ../.
> ??? (Recursive I guess)?When in parent without
__init__.py
ofspam
with__init__.py
:pylint .
> Recursive, findsspam
pylint spam
> Not recursivepylint
> Exit without doing anything.pylint ../.
> ??? (Recursive I guess)?For
3.0
. In bold is those that changed compared to2.x
:When in
spam
without__init__.py
:pylint .
> Recursivepylint
> TBD.pylint ../spam
> RecursiveWhen in
spam
with__init__.py
:pylint .
> Recursivepylint
> TBD.pylint ../spam
> RecursiveWhen in parent without
__init__.py
ofspam
without__init__.py
:pylint .
> Recursive, findsspam
pylint spam
> Recursivepylint
> TBD.pylint ../.
> RecursiveWhen in parent without
__init__.py
ofspam
with__init__.py
:pylint .
> Recursive, findsspam
pylint spam
> Recursivepylint
> TBDpylint ../.
> RecursiveThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say those should indeed be recursive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last commit implements default recursive mode when
.
directory is passed to pylint.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this comment as unresolved as it is quite important for future people looking back at this PR and it might get easily lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably even go in
tests/conftest.py
to be used everywhere ? I don't know how frequent it is. But we might want to do that in another MR, this one need to be merged πThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are simple yet effective. Very nice π