summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDani Alcala <112832187+clavedeluna@users.noreply.github.com>2022-12-03 05:21:44 -0300
committerGitHub <noreply@github.com>2022-12-03 09:21:44 +0100
commit30c931f5170f6b83d8762993fdaa534e207b4324 (patch)
tree368cf9a1b31233696e456467def5d031a2121c75
parent1a81b16f6113b10233279a0cdfde61c30decaac3 (diff)
downloadpylint-git-30c931f5170f6b83d8762993fdaa534e207b4324.tar.gz
add test and expl for line-too-long useless-supp FP (#7887)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--doc/data/messages/l/line-too-long/details.rst3
-rw-r--r--doc/whatsnew/fragments/3368.false_positive3
-rw-r--r--tests/regrtest_data/line_too_long_no_code.py2
-rw-r--r--tests/test_self.py18
4 files changed, 26 insertions, 0 deletions
diff --git a/doc/data/messages/l/line-too-long/details.rst b/doc/data/messages/l/line-too-long/details.rst
new file mode 100644
index 000000000..068a453b4
--- /dev/null
+++ b/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.
diff --git a/doc/whatsnew/fragments/3368.false_positive b/doc/whatsnew/fragments/3368.false_positive
new file mode 100644
index 000000000..bdfa7de6c
--- /dev/null
+++ b/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
diff --git a/tests/regrtest_data/line_too_long_no_code.py b/tests/regrtest_data/line_too_long_no_code.py
new file mode 100644
index 000000000..75ab07fc2
--- /dev/null
+++ b/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
diff --git a/tests/test_self.py b/tests/test_self.py
index 587b8bb58..02e1a17e8 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -1247,6 +1247,24 @@ a.py:1:4: E0001: Parsing failed: 'invalid syntax (<unknown>, line 1)' (syntax-er
[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."""