diff options
author | Federico Bond <federicobond@gmail.com> | 2019-02-14 13:17:05 -0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-02-14 17:17:04 +0100 |
commit | 5b2354306e7e608ca02479edd99e5255d13bd0fa (patch) | |
tree | da98c679a00b128f4d21e1aa0b6b2af864b3b90e | |
parent | ad8db4c69bbe33f5d805388383e1f0954fcb4b40 (diff) | |
download | pylint-git-5b2354306e7e608ca02479edd99e5255d13bd0fa.tar.gz |
Fix not-callable false positive on uninferable property (#2748)
-rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | pylint/checkers/typecheck.py | 2 | ||||
-rw-r--r-- | pylint/test/unittest_checker_typecheck.py | 18 |
4 files changed, 23 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 448eb880d..fc905aeaa 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -267,3 +267,5 @@ contributors: * Pascal Corpet * Svetoslav Neykov: contributor + +* Federico Bond: contributor @@ -124,6 +124,8 @@ Release date: TBA The number of arguments was not handled properly, leading to an always successful check. +* Fix false positive ``not-callable`` for uninferable properties. + What's New in Pylint 2.2.2? =========================== diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py index 14523766e..8f26e0b4f 100644 --- a/pylint/checkers/typecheck.py +++ b/pylint/checkers/typecheck.py @@ -1022,7 +1022,7 @@ accessed. Python regular expressions are accepted.", try: all_returns_are_callable = all( - return_node.callable() + return_node.callable() or return_node is astroid.Uninferable for return_node in attr.infer_call_result(node) ) except astroid.InferenceError: diff --git a/pylint/test/unittest_checker_typecheck.py b/pylint/test/unittest_checker_typecheck.py index 173210cf1..71fa7e82b 100644 --- a/pylint/test/unittest_checker_typecheck.py +++ b/pylint/test/unittest_checker_typecheck.py @@ -297,6 +297,24 @@ class TestTypeChecker(CheckerTestCase): with self.assertNoMessages(): self.checker.visit_call(call) + def test_not_callable_uninferable_property(self): + """Make sure not-callable isn't raised for uninferable + properties + """ + call = astroid.extract_node( + """ + class A: + @property + def call(self): + return undefined + + a = A() + a.call() #@ + """ + ) + with self.assertNoMessages(): + self.checker.visit_call(call) + def test_descriptor_call(self): call = astroid.extract_node( """ |