summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-05-05 14:12:59 +0200
committerGitHub <noreply@github.com>2022-05-05 14:12:59 +0200
commita422b7f0f4315332a09b0787d4b4fd53959e6dd1 (patch)
tree9ea7ff179c931987a970916e1dbf749a500e745c
parent647b05e964779f5bd0d449998580a37344784c0a (diff)
downloadpylint-git-a422b7f0f4315332a09b0787d4b4fd53959e6dd1.tar.gz
Change default values of ``ignore-imports`` and ``ignore-signatures`` (#6500)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
-rw-r--r--ChangeLog3
-rw-r--r--doc/whatsnew/2.14.rst3
-rw-r--r--pylint/checkers/similar.py4
-rw-r--r--tests/checkers/unittest_similar.py2
4 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 7586f1378..98d71e962 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,9 @@ Release date: TBA
Closes #4301
+* By default the similarity checker will now ignore imports and ignore function signatures when computing
+ duplication. If you want to keep the previous behaviour set ``ignore-imports`` and ``ignore-signatures`` to ``False``.
+
* Improved recognition of namespace packages. They should no longer be added to ``sys.path``
which should prevent various issues with false positives.
Because of the difficulties with mirroring the python import mechanics we would gladly
diff --git a/doc/whatsnew/2.14.rst b/doc/whatsnew/2.14.rst
index 2931fae03..064832ea2 100644
--- a/doc/whatsnew/2.14.rst
+++ b/doc/whatsnew/2.14.rst
@@ -278,6 +278,9 @@ Other Changes
Closes #5608
+* By default the similarity checker will now ignore imports and ignore function signatures when computing
+ duplication. If you want to keep the previous behaviour set ``ignore-imports`` and ``ignore-signatures`` to ``False``.
+
* Pylint now expands the user path (i.e. ``~`` to ``home/yusef/``) and expands environment variables (i.e. ``home/$USER/$project``
to ``home/yusef/pylint`` for ``USER=yusef`` and ``project=pylint``) for pyreverse's ``output-directory``,
``import-graph``, ``ext-import-graph``, ``int-import-graph`` options, and the spell checker's ``spelling-private-dict-file``
diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py
index 74296f0fe..f034650fd 100644
--- a/pylint/checkers/similar.py
+++ b/pylint/checkers/similar.py
@@ -780,7 +780,7 @@ class SimilarChecker(BaseRawFileChecker, Similar):
(
"ignore-imports",
{
- "default": False,
+ "default": True,
"type": "yn",
"metavar": "<y or n>",
"help": "Imports are removed from the similarity computation",
@@ -789,7 +789,7 @@ class SimilarChecker(BaseRawFileChecker, Similar):
(
"ignore-signatures",
{
- "default": False,
+ "default": True,
"type": "yn",
"metavar": "<y or n>",
"help": "Signatures are removed from the similarity computation",
diff --git a/tests/checkers/unittest_similar.py b/tests/checkers/unittest_similar.py
index a14eabe40..c0f0cdcbf 100644
--- a/tests/checkers/unittest_similar.py
+++ b/tests/checkers/unittest_similar.py
@@ -469,6 +469,8 @@ def test_get_map_data() -> None:
# Manually perform a 'map' type function
for source_fname in source_streams:
sim = similar.SimilarChecker(PyLinter())
+ sim.linter.set_option("ignore-imports", False)
+ sim.linter.set_option("ignore-signatures", False)
with open(source_fname, encoding="utf-8") as stream:
sim.append_stream(source_fname, stream)
# The map bit, can you tell? ;)