summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2021-10-19 08:48:35 +0200
committerDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2021-10-19 09:03:21 +0200
commit27cabbbb1f950c64c2f4a80bfcf005a694ae14a6 (patch)
treeb6274d53499e35eb2e8e43a87ade24f84cd58f79
parentcd5838c14c58d6904433e9037ec20071eb897185 (diff)
downloadpylint-git-27cabbbb1f950c64c2f4a80bfcf005a694ae14a6.tar.gz
Fix double emitting of ``not-callable`` on inferrable ``properties``
Closes #4426
-rw-r--r--ChangeLog4
-rw-r--r--doc/whatsnew/2.12.rst4
-rw-r--r--pylint/checkers/typecheck.py3
-rw-r--r--tests/functional/n/not_callable.py10
-rw-r--r--tests/functional/n/not_callable.txt17
5 files changed, 29 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b5461d12..c97467f74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -75,6 +75,10 @@ Release date: TBA
Closes #3031
+* Fix double emitting of ``not-callable`` on inferrable ``properties``
+
+ Closes #4426
+
* Fix ``missing-function-docstring`` not being able to check ``__init__`` and other
magic methods even if the ``no-docstring-rgx`` setting was set to do so
diff --git a/doc/whatsnew/2.12.rst b/doc/whatsnew/2.12.rst
index 4af23d50b..5f9fcb976 100644
--- a/doc/whatsnew/2.12.rst
+++ b/doc/whatsnew/2.12.rst
@@ -75,6 +75,10 @@ Other Changes
Closes #4031
+* Fix double emitting of ``not-callable`` on inferrable ``properties``
+
+ Closes #4426
+
* ``mising-param-doc`` now correctly parses asterisks for variable length and
keyword parameters
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index 029f3e7f5..8fa80ee21 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -1296,8 +1296,9 @@ accessed. Python regular expressions are accepted.",
pass
else:
self.add_message("not-callable", node=node, args=node.func.as_string())
+ else:
+ self._check_uninferable_call(node)
- self._check_uninferable_call(node)
try:
called, implicit_args, callable_name = _determine_callable(called)
except ValueError:
diff --git a/tests/functional/n/not_callable.py b/tests/functional/n/not_callable.py
index 01a9009bf..7c361aa6a 100644
--- a/tests/functional/n/not_callable.py
+++ b/tests/functional/n/not_callable.py
@@ -123,3 +123,13 @@ class UnknownBaseCallable(missing.Blah):
pass
UnknownBaseCallable()()
+
+# Regression test for #4426
+# If property is inferrable we shouldn't double emit the message
+# See: https://github.com/PyCQA/pylint/issues/4426
+class ClassWithProperty:
+ @property
+ def value(self):
+ return 42
+
+CLASS_WITH_PROP = ClassWithProperty().value() # [not-callable]
diff --git a/tests/functional/n/not_callable.txt b/tests/functional/n/not_callable.txt
index 397e617b6..7926cb32b 100644
--- a/tests/functional/n/not_callable.txt
+++ b/tests/functional/n/not_callable.txt
@@ -1,8 +1,9 @@
-not-callable:5:0::REVISION is not callable
-not-callable:23:12::INSTANCE is not callable
-not-callable:25:12::LIST is not callable
-not-callable:27:12::DICT is not callable
-not-callable:29:12::TUPLE is not callable
-not-callable:31:12::INT is not callable
-not-callable:66:0::PROP.test is not callable
-not-callable:67:0::PROP.custom is not callable
+not-callable:5:0::REVISION is not callable:HIGH
+not-callable:23:12::INSTANCE is not callable:HIGH
+not-callable:25:12::LIST is not callable:HIGH
+not-callable:27:12::DICT is not callable:HIGH
+not-callable:29:12::TUPLE is not callable:HIGH
+not-callable:31:12::INT is not callable:HIGH
+not-callable:66:0::PROP.test is not callable:HIGH
+not-callable:67:0::PROP.custom is not callable:HIGH
+not-callable:135:18::ClassWithProperty().value is not callable:HIGH