summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-06-18 08:43:52 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-06-18 09:00:07 +0200
commit4e2529cebbc0efc4f6bb54902fc9eadf9052f0a3 (patch)
tree72c6c7a7bc89b0f244c9072f1f8762b1660be2ac
parent9cdd479cafe095270f4df8f2575ed304c85d0eca (diff)
downloadpylint-git-4e2529cebbc0efc4f6bb54902fc9eadf9052f0a3.tar.gz
Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`
Close #3690
-rw-r--r--ChangeLog4
-rw-r--r--pylint/checkers/base.py11
-rw-r--r--tests/functional/r/regression_infer_call_result_3690.py11
3 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 0db4e9bb0..3d0f8de51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@ What's New in Pylint 2.5.4?
Release date: TBA
+* Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`
+
+ Close #3690
+
What's New in Pylint 2.5.3?
===========================
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index 582b0fdeb..1b6902c24 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1134,10 +1134,13 @@ class BasicChecker(_BasicChecker):
# If the constant node is a FunctionDef or Lambda then
#  it may be a illicit function call due to missing parentheses
call_inferred = None
- if isinstance(inferred, astroid.FunctionDef):
- call_inferred = inferred.infer_call_result()
- elif isinstance(inferred, astroid.Lambda):
- call_inferred = inferred.infer_call_result(node)
+ try:
+ if isinstance(inferred, astroid.FunctionDef):
+ call_inferred = inferred.infer_call_result()
+ elif isinstance(inferred, astroid.Lambda):
+ call_inferred = inferred.infer_call_result(node)
+ except astroid.InferenceError:
+ call_inferred = None
if call_inferred:
try:
for inf_call in call_inferred:
diff --git a/tests/functional/r/regression_infer_call_result_3690.py b/tests/functional/r/regression_infer_call_result_3690.py
new file mode 100644
index 000000000..0949d9439
--- /dev/null
+++ b/tests/functional/r/regression_infer_call_result_3690.py
@@ -0,0 +1,11 @@
+# pylint: disable-msg=missing-docstring,too-few-public-methods,using-constant-test
+
+class Class:
+ @property
+ @classmethod
+ def func(cls):
+ pass
+
+
+if Class.func:
+ pass