Skip to content

Commit

Permalink
Fix double emitting of not-callable on inferrable properties
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Oct 19, 2021
1 parent cd5838c commit 27cabbb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions doc/whatsnew/2.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,9 @@ def visit_call(self, node: nodes.Call) -> None:
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:
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/n/not_callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
17 changes: 9 additions & 8 deletions tests/functional/n/not_callable.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 27cabbb

Please sign in to comment.