Skip to content

Commit

Permalink
add test and expl for line-too-long useless-supp FP (#7887)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
(cherry picked from commit 30c931f)
  • Loading branch information
clavedeluna authored and Pierre-Sassoulas committed Dec 4, 2022
1 parent e1856b2 commit ad51069
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
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 false positive of ``useless-suppression`` we can't easily fix.

See https://github.com/PyCQA/pylint/issues/3368 for more information.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/3368.false_positive
@@ -0,0 +1,3 @@
Document a known false positive for ``useless-suppression`` when disabling ``line-too-long`` in a module with only comments and no code.

Closes #3368
2 changes: 2 additions & 0 deletions tests/regrtest_data/line_too_long_no_code.py
@@ -0,0 +1,2 @@
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 # pylint: disable=line-too-long
# See https://github.com/PyCQA/pylint/issues/3368
18 changes: 18 additions & 0 deletions tests/test_self.py
Expand Up @@ -1215,6 +1215,24 @@ 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 a known false positive for useless-suppression
See https://github.com/PyCQA/pylint/issues/3368
If you manage to make this test fail and remove the useless-suppression
warning please contact open a Pylint PR!
"""
module = join(HERE, "regrtest_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)


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

0 comments on commit ad51069

Please sign in to comment.