Skip to content
Snippets Groups Projects
Commit 2c1e4954 authored by Claudiu Popa's avatar Claudiu Popa
Browse files

Make sure to handle Uninferable by returning it rather than returning an exception

parent ceb81955
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -550,6 +550,8 @@ def infer_isinstance(callnode, context=None):
raise UseInferenceDefault("TypeError: " + str(exc))
except AstroidError:
raise UseInferenceDefault
if isinstance_bool is util.Uninferable:
raise UseInferenceDefault
return nodes.Const(isinstance_bool)
 
 
Loading
Loading
Loading
Loading
@@ -100,8 +100,8 @@ def object_isinstance(node, class_or_seq, context=None):
class_seq = class_or_seq
obj_type = object_type(node, context)
if obj_type is util.Uninferable:
return exceptions.InferenceError(
"{node} cannot be inferred".format(node=node))
return util.Uninferable
# Instances are not types
class_seq = [item if not isinstance(item, bases.Instance)
else util.Uninferable for item in class_seq]
Loading
Loading
Loading
Loading
@@ -997,6 +997,10 @@ class TestIsinstanceInference:
with pytest.raises(astroid.InferenceError):
_get_result_node("isinstance(1, int, str)")
 
def test_first_param_is_uninferable(self):
with pytest.raises(astroid.InferenceError):
_get_result_node('isinstance(something, int)')
 
def _get_result_node(code):
node = next(astroid.extract_node(code).infer())
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment