mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-24 17:28:36 +08:00
Fix the last remaining issues with ahead of time annotations, see #982
This commit is contained in:
@@ -443,16 +443,16 @@ def _remove_statements(evaluator, context, stmt, name):
|
|||||||
def tree_name_to_contexts(evaluator, context, tree_name):
|
def tree_name_to_contexts(evaluator, context, tree_name):
|
||||||
|
|
||||||
context_set = ContextSet()
|
context_set = ContextSet()
|
||||||
module = context.get_root_context().tree_node
|
module_node = context.get_root_context().tree_node
|
||||||
names = module.get_used_names().get(tree_name.value)
|
if module_node is not None:
|
||||||
for name in names:
|
names = module_node.get_used_names().get(tree_name.value, [])
|
||||||
expr_stmt = name.parent
|
for name in names:
|
||||||
|
expr_stmt = name.parent
|
||||||
|
|
||||||
correct_scope = parser_utils.get_parent_scope(name) == context.tree_node
|
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:
|
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])
|
||||||
context_set |= _evaluate_for_annotation(context, expr_stmt.children[1].children[1])
|
|
||||||
|
|
||||||
if context_set:
|
if context_set:
|
||||||
return context_set
|
return context_set
|
||||||
|
|||||||
@@ -24,11 +24,3 @@ char: str
|
|||||||
for char in test_string:
|
for char in test_string:
|
||||||
#? str()
|
#? str()
|
||||||
char
|
char
|
||||||
|
|
||||||
|
|
||||||
import numpy
|
|
||||||
somearrays = [numpy.ones((10, 10)), numpy.eye(10), 2, 2.3]
|
|
||||||
array : numpy.ndarray
|
|
||||||
for array in somearrays[0:2]:
|
|
||||||
#? numpy.ndarray()
|
|
||||||
array
|
|
||||||
|
|||||||
Reference in New Issue
Block a user