Skip to content

Commit 36250aa

Browse files
committed
Fix a crash caused by not guarding against InferenceError when calling infer_call_result
Close #3690
1 parent 5016fd1 commit 36250aa

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ Release date: TBA
3434

3535
* Fix `pre-commit` config that could lead to undetected duplicate lines of code
3636

37+
38+
What's New in Pylint 2.5.4?
39+
===========================
40+
41+
* Fix a crash caused by not guarding against `InferenceError` when calling `infer_call_result`
42+
43+
Close #3690
44+
45+
3746
What's New in Pylint 2.5.3?
3847
===========================
3948

pylint/checkers/base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,10 +1134,13 @@ def _check_using_constant_test(self, node, test):
11341134
# If the constant node is a FunctionDef or Lambda then
11351135
#  it may be a illicit function call due to missing parentheses
11361136
call_inferred = None
1137-
if isinstance(inferred, astroid.FunctionDef):
1138-
call_inferred = inferred.infer_call_result()
1139-
elif isinstance(inferred, astroid.Lambda):
1140-
call_inferred = inferred.infer_call_result(node)
1137+
try:
1138+
if isinstance(inferred, astroid.FunctionDef):
1139+
call_inferred = inferred.infer_call_result()
1140+
elif isinstance(inferred, astroid.Lambda):
1141+
call_inferred = inferred.infer_call_result(node)
1142+
except astroid.InferenceError:
1143+
call_inferred = None
11411144
if call_inferred:
11421145
try:
11431146
for inf_call in call_inferred:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# pylint: disable-msg=missing-docstring,too-few-public-methods,using-constant-test
2+
3+
class Class:
4+
@property
5+
@classmethod
6+
def func(cls):
7+
pass
8+
9+
10+
if Class.func:
11+
pass

0 commit comments

Comments
 (0)