Skip to content

Commit 438025d

Browse files
add test and expl for line-too-long useless-supp FP (#7887)
Co-authored-by: Pierre Sassoulas <[email protected]> (cherry picked from commit 30c931f)
1 parent 19c0534 commit 438025d

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
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.
2+
3+
See https://github.com/PyCQA/pylint/issues/3368 for more information.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Document a known false positive for ``useless-suppression`` when disabling ``line-too-long`` in a module with only comments and no code.
2+
3+
Closes #3368
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 # pylint: disable=line-too-long
2+
# See https://github.com/PyCQA/pylint/issues/3368

tests/test_self.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,24 @@ def test_encoding(self, module_name: str, expected_output: str) -> None:
12151215
[path], expected_output=expected_output, unexpected_output="(astroid-error)"
12161216
)
12171217

1218+
def test_line_too_long_useless_suppression(self) -> None:
1219+
"""A test that demonstrates a known false positive for useless-suppression
1220+
1221+
See https://github.com/PyCQA/pylint/issues/3368
1222+
1223+
If you manage to make this test fail and remove the useless-suppression
1224+
warning please contact open a Pylint PR!
1225+
"""
1226+
module = join(HERE, "regrtest_data", "line_too_long_no_code.py")
1227+
expected = textwrap.dedent(
1228+
f"""
1229+
{module}:1:0: I0011: Locally disabling line-too-long (C0301) (locally-disabled)
1230+
{module}:1:0: I0021: Useless suppression of 'line-too-long' (useless-suppression)
1231+
"""
1232+
)
1233+
1234+
self._test_output([module, "--enable=all"], expected_output=expected)
1235+
12181236

12191237
class TestCallbackOptions:
12201238
"""Test for all callback options we support."""

0 commit comments

Comments
 (0)