-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make pylint consider disable params
when checking for line length
#4802
Comments
Wow, I did not understand that the current behavior was to exclude the length of the comment. You're right to have insisted ! Clearly in my mind the default should be to take the real length of the line into account. We could maybe suggest to put the comment on the line above if it's the comment that is causing the problem (and to use |
Hmm perhaps, but for those cases users will already have disabled |
The issue I was seeing is if pylint is suggesting to move a noqa from flake8 to the line above when it's in fact impossible. Maybe we don't need to handle that use case. @cdce8p do you have an opinion ? |
There seem to be valid arguments for both sides, with or without comments. Tbh I don't really like either that much. Should we still have this check when |
We only document the one that are redundant if you're already using another linter, because some users want to just use pylint exclusively. Because of that removing checkers from the default is only decided on the checker's own merit regardless of another linter doing it or not. With the exception of very hard to maintain checks (like bad-indentation when black can do the formatting). For this issue I suggest we take the real line length into account for |
I would suggest keeping the default excluding the comments. Even though there are now This happens both to existing code, and when you write new code interactively. When you add a trailing Also, I've collected some stats over our internal code base regarding how often our trailing
So that happens a lot to existing code base that's used to the current Pylint behavior. |
@yilei Thanks for the thorough investigation! Based on this I think it makes sense to keep excluding comments from line length. This seems like a major breaking change and if I had to change +-1200 lines just to be able to upgrade to Although I think it makes sense to do this, with the current status quo I'm -1 on this proposal. |
Thanks you for the feedback @yilei, I did not realize the change would create that much work. Clearly we can't do it unless we automate the move to Should we close @DanielNoord ? |
I think an I think so... Although we might want to document this somewhere a little more explicitly? |
+1 for auto-fixer to be its own project to separate concerns. |
I'll open an issue for autofixing. Let's close this issue with a documentation merge request then ? |
Current problem
As discussed in #1682
pylint
currently does not consider the length of the disable params when checking for line length.For example, when max-length is set to 80 the following code would not raise a
line-too-long
warning.According to the issue, this is due to:
/~https://github.com/PyCQA/pylint/blob/14da5ce258d3818037304a6e0f61aba1462e251d/pylint/checkers/format.py#L1004
Which seems fair.
However, this is not what users might intuitively expect from this warning, as a comment in that issue shows. Some users might want the max-length to also include comments.
Although #4797 fixes some of the issues in the original issue, it does not solve this particular issue. This issue serves to track it.
Desired solution
Make
pylint
consider comments when checking for max-length of lines.Open question:
What should be default behaviour? Including comments or excluding comments? Current behaviour is excluding, but I would argue that it would be more intuitive to include them. Especially now that users can use
disable-next
to split comments and code over multiple lines.The text was updated successfully, but these errors were encountered: