Make sure that infering params is possible from the API

This commit is contained in:
Dave Halter
2019-12-27 10:36:13 +01:00
parent 02320f832d
commit 5a54d94aa5
2 changed files with 21 additions and 0 deletions

View File

@@ -169,6 +169,8 @@ class InferenceState(object):
return imports.infer_import(context, name)
if type_ == 'with_stmt':
return tree_name_to_values(self, context, name)
elif type_ == 'param':
return context.py__getattribute__(name.value, position=name.end_pos)
else:
result = follow_error_node_imports_if_possible(context, name)
if result is not None:

View File

@@ -299,6 +299,25 @@ except MyException as e:
for x in e.my_attr:
pass
# -----------------
# params
# -----------------
my_param = 1
#? 9 str()
def foo1(my_param):
my_param = 3.0
foo1("")
my_type = float()
#? 20 float()
def foo2(my_param: my_type):
pass
foo2("")
#? 20 int()
def foo3(my_param=my_param):
pass
foo3("")
# -----------------
# continuations