forked from VimPlug/jedi
add ahead of time annotations PEP 526
This commit is contained in:
@@ -17,6 +17,7 @@ from jedi.evaluate import helpers
|
||||
from jedi.evaluate import analysis
|
||||
from jedi.evaluate import imports
|
||||
from jedi.evaluate import arguments
|
||||
from jedi.evaluate.pep0484 import _evaluate_for_annotation
|
||||
from jedi.evaluate.context import ClassContext, FunctionContext
|
||||
from jedi.evaluate.context import iterable
|
||||
from jedi.evaluate.context import TreeInstance, CompiledInstance
|
||||
@@ -442,6 +443,22 @@ def _remove_statements(evaluator, context, stmt, name):
|
||||
|
||||
|
||||
def tree_name_to_contexts(evaluator, context, tree_name):
|
||||
|
||||
context_set = ContextSet()
|
||||
module = context.get_root_context().tree_node
|
||||
names = module.get_used_names().get(tree_name.value)
|
||||
for name in names:
|
||||
expr_stmt = name.parent
|
||||
|
||||
correct_scope = parser_utils.get_parent_scope(name) == context.tree_node
|
||||
|
||||
if expr_stmt.type == "expr_stmt" and expr_stmt.children[1].type == "annassign" and correct_scope:
|
||||
print("found node in correct scope!", expr_stmt.children[1].children[1])
|
||||
context_set |= _evaluate_for_annotation(context, expr_stmt.children[1].children[1])
|
||||
|
||||
if context_set:
|
||||
return context_set
|
||||
|
||||
types = []
|
||||
node = tree_name.get_definition(import_name_always=True)
|
||||
if node is None:
|
||||
|
||||
Reference in New Issue
Block a user