-
-
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
Useful 'line-too-long' suppression considered useless #3368
Comments
Thanks for the report! |
@PCManticore A TODO in one of our projects reminded me of this issue and it still seems to be around. |
@PCManticore Up ? |
Any news about it ? |
Hello, no one worked on it yet, but contributions are welcome :) |
I think something might have changed in the checker. I now get: ❯ cat test.py
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 # pylint: disable=line-too-long
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
❯ pylint -e useless-suppression --max-line-length=120 'test.py'
************* Module test
test.py:3:0: I0021: Useless suppression of 'line-too-long' (useless-suppression) Do we still consider this a false positive? |
Hi @DanielNoord, |
This also affects triple-quoted strings, e.g.: '''
This line is much too long. It's long enough to cause a warning. ======================
''' # pylint: disable=line-too-long This case was described in detail in #5749, which Pierre has very reasonably judged to be a duplicate of this issue. |
Output mentioned above
is the output if we run it with
the last line is the FP to target |
I've narrowed down the issue. This only affects modules with no code, only with comments with # or with """. This can be tested by adding any other line that is code to the module, and you'll see the The issue is triggered to do this line. When Could a maintainer suggest a way to get around this? Either by somehow adding the code "child" to the node via astroid, or by suggesting a way around this. I tried stuff like |
I haven't looked into this, but this might be unfixable. Children of "empty" modules can't really be made up and I'm not in favour of adding them arbitrarily to Module nodes just so we can fix this edge case. It would be interesting to know whether this issue also occurs if any actual code is in the module, both before and after the comments. |
The I spent quite a bit of time trying to see how this could reasonably be fixed and I've concluded as you have, it seems unfixable. I think we could close this issue as won't fix and for documentation purposes, add the FP as a functional test, what do you think? |
We can document this in the details.rst of line-too-long too. |
Thanks for fixing this @clavedeluna! I think you found a nice solution here! |
Really satisfying to close this! |
With apologies for being the bearer of bad news, I'm not sure this issue is (completely) resolved. Consider: # pylint: disable=missing-module-docstring,unused-argument
# pylint: disable=missing-function-docstring,unused-variable
def first_case() -> None:
# next line generates 'line-too-long' error (as it should)
def my_function(aaa: int, bbb: int, ccc: int, ddd: int) -> int: # pragma: no cover
return 0
def second_case() -> None:
# next line generates 'useless-suppression' (which is wrong)
def my_function(aaa: int, bbb: int, ccc: int, ddd: int) -> int: # pragma: no cover # pylint: disable=line-too-long
return 0
def third_case() -> None:
# this case works as expected
# pylint: disable-next=line-too-long
def my_function(aaa: int, bbb: int, ccc: int, ddd: int) -> int: # pragma: no cover
return 0 Analyzing the above with
As can be seen above, the [Edited to add version information:]
|
@finite-state-machine Thanks for the test case. What it shows is actually slightly different than the test cases for this issue, which were for comments only. Could you open a separate issue? |
Maaaybe? Turns out if you run some different commands results vary:
worth investigating for sure |
Steps to reproduce
Run
pylint -e useless-suppression --max-line-length=120 toolong.py
wheretoolong.py
's content is:Current output
Expected behavior
pylint --version output
The text was updated successfully, but these errors were encountered: