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 test and expl for line-too-long useless-supp FP #7887

Merged
merged 3 commits into from Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/data/messages/l/line-too-long/details.rst
@@ -0,0 +1,3 @@
If you attempt to disable this message via ``# pylint: disable=line-too-long`` in a module with no code, you may receive a message for ``useless-suppression``. This is a currently acceptable false positive for ``useless-suppression``.

clavedeluna marked this conversation as resolved.
Show resolved Hide resolved
See https://github.com/PyCQA/pylint/issues/3368 for more information.
2 changes: 2 additions & 0 deletions doc/whatsnew/fragments/3368.false_positive
@@ -0,0 +1,2 @@
Document an acceptable false positive for ``useless-suppression`` when disabling ``line-too-long`` in a module with only comments and no code.
clavedeluna marked this conversation as resolved.
Show resolved Hide resolved
Closes #3368
1 change: 1 addition & 0 deletions tests/data/line_too_long_no_code.py
@@ -0,0 +1 @@
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 # pylint: disable=line-too-long
clavedeluna marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions tests/test_self.py
Expand Up @@ -1247,6 +1247,21 @@ def test_encoding(self, module_name: str, expected_output: str) -> None:
[path], expected_output=expected_output, unexpected_output="(astroid-error)"
)

def test_line_too_long_useless_suppression(self) -> None:
"""A test that demonstrates an acceptable false positive for useless-suppression

See https://github.com/PyCQA/pylint/issues/3368
"""
module = join(HERE, "data", "line_too_long_no_code.py")
expected = textwrap.dedent(
f"""
{module}:1:0: I0011: Locally disabling line-too-long (C0301) (locally-disabled)
{module}:1:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
"""
)

self._test_output([module, "--enable=all"], expected_output=expected)

clavedeluna marked this conversation as resolved.
Show resolved Hide resolved

class TestCallbackOptions:
"""Test for all callback options we support."""
Expand Down