forked from VimPlug/jedi
Cleanup with_stmt.
This commit is contained in:
@@ -192,7 +192,7 @@ def _name_to_types(evaluator, context, tree_name):
|
|||||||
elif typ == 'expr_stmt':
|
elif typ == 'expr_stmt':
|
||||||
types = _remove_statements(evaluator, context, node, tree_name)
|
types = _remove_statements(evaluator, context, node, tree_name)
|
||||||
elif typ == 'with_stmt':
|
elif typ == 'with_stmt':
|
||||||
types = context.eval_node(node.node_from_name(tree_name))
|
types = context.eval_node(node.get_context_manager_from_name(tree_name))
|
||||||
elif typ in ('import_from', 'import_name'):
|
elif typ in ('import_from', 'import_name'):
|
||||||
types = imports.infer_import(context, tree_name)
|
types = imports.infer_import(context, tree_name)
|
||||||
elif typ in ('funcdef', 'classdef'):
|
elif typ in ('funcdef', 'classdef'):
|
||||||
|
|||||||
@@ -789,12 +789,11 @@ class WithStmt(Flow):
|
|||||||
names += _defined_names(with_item.children[2])
|
names += _defined_names(with_item.children[2])
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def node_from_name(self, name):
|
def get_context_manager_from_name(self, name):
|
||||||
node = name
|
node = name.parent
|
||||||
while True:
|
if node.type != 'with_item':
|
||||||
node = node.parent
|
raise ValueError('The name is not actually part of a with statement.')
|
||||||
if node.type == 'with_item':
|
return node.children[0]
|
||||||
return node.children[0]
|
|
||||||
|
|
||||||
|
|
||||||
class Import(PythonBaseNode):
|
class Import(PythonBaseNode):
|
||||||
|
|||||||
Reference in New Issue
Block a user