1
0
forked from VimPlug/jedi

typing.Union and typing.Optional

This commit is contained in:
Claude
2015-12-31 01:59:34 +01:00
parent 7b97312509
commit 3852431549
2 changed files with 34 additions and 0 deletions
+7
View File
@@ -110,6 +110,13 @@ def get_types_for_typing_module(evaluator, typ, node):
nodes = node.children[::2] # skip the commas
else:
nodes = [node]
del node
# hacked in Union and Optional, since it's hard to do nicely in parsed code
if typ.name.value == "Union":
return set().union(*[evaluator.eval_element(node) for node in nodes])
if typ.name.value == "Optional":
return evaluator.eval_element(nodes[0])
typing = _get_typing_replacement_module()
factories = evaluator.find_types(typing, "factory")