diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-05-05 14:03:06 +0200 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2022-05-05 14:15:39 +0200 |
commit | 52b88986932f77761e724fde9dc19fc4f0d1054e (patch) | |
tree | 94e07d8aca1d108c5f9fd7f68fefb28f6d6fc8e9 | |
parent | a422b7f0f4315332a09b0787d4b4fd53959e6dd1 (diff) | |
download | pylint-git-52b88986932f77761e724fde9dc19fc4f0d1054e.tar.gz |
Do not report useless-suppression on duplicate-code
-rw-r--r-- | pylint/constants.py | 1 | ||||
-rw-r--r-- | tests/regrtest_data/duplicate_code/useless_suppression/__init__.py | 0 | ||||
-rw-r--r-- | tests/regrtest_data/duplicate_code/useless_suppression/file_one.py | 7 | ||||
-rw-r--r-- | tests/regrtest_data/duplicate_code/useless_suppression/file_two.py | 5 | ||||
-rw-r--r-- | tests/test_similar.py | 18 |
5 files changed, 31 insertions, 0 deletions
diff --git a/pylint/constants.py b/pylint/constants.py index de98fbee0..90e2b734e 100644 --- a/pylint/constants.py +++ b/pylint/constants.py @@ -203,6 +203,7 @@ INCOMPATIBLE_WITH_USELESS_SUPPRESSION = frozenset( "W1511", # deprecated-argument "W1512", # deprecated-class "W1513", # deprecated-decorator + "R0801", # duplicate-code ] ) diff --git a/tests/regrtest_data/duplicate_code/useless_suppression/__init__.py b/tests/regrtest_data/duplicate_code/useless_suppression/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/regrtest_data/duplicate_code/useless_suppression/__init__.py diff --git a/tests/regrtest_data/duplicate_code/useless_suppression/file_one.py b/tests/regrtest_data/duplicate_code/useless_suppression/file_one.py new file mode 100644 index 000000000..81c90e2e0 --- /dev/null +++ b/tests/regrtest_data/duplicate_code/useless_suppression/file_one.py @@ -0,0 +1,7 @@ +# pylint: disable=duplicate-code + +import argparse +import math +import os +import random +import sys diff --git a/tests/regrtest_data/duplicate_code/useless_suppression/file_two.py b/tests/regrtest_data/duplicate_code/useless_suppression/file_two.py new file mode 100644 index 000000000..d1849ed44 --- /dev/null +++ b/tests/regrtest_data/duplicate_code/useless_suppression/file_two.py @@ -0,0 +1,5 @@ +import argparse +import math +import os +import random +import sys diff --git a/tests/test_similar.py b/tests/test_similar.py index 02db89d41..cf9e8be5c 100644 --- a/tests/test_similar.py +++ b/tests/test_similar.py @@ -13,6 +13,7 @@ from typing import TextIO import pytest +from pylint.reporters.text import TextReporter from pylint.testutils._run import _Run as Run from pylint.testutils.utils import _patch_streams @@ -218,3 +219,20 @@ class TestSimilarCodeChecker: [path, "-e=duplicate-code", "-d=unused-import,C", "--ignore-imports=y"], code=0, ) + + @staticmethod + def test_useless_suppression() -> None: + """Tests that duplicate code and useless-suppression work well together.""" + path = join(DATA, "useless_suppression") + pylint_output = StringIO() + reporter = TextReporter(pylint_output) + runner = Run( + [ + path, + "-e=duplicate-code, useless-suppression", + "-d=missing-module-docstring, unused-import", + ], + reporter=reporter, + exit=False, + ) + assert not runner.linter.stats.by_msg |