mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-21 22:28:27 +08:00
Fix param position lookups. Also forward annotations have the correct resolution path now (starting at the end of the file).
This commit is contained in:
@@ -322,6 +322,13 @@ class Evaluator(object):
|
||||
# This is the first global lookup.
|
||||
stmt = atom.get_definition()
|
||||
scope = stmt.get_parent_until(tree.IsScope, include_current=True)
|
||||
if isinstance(scope, (tree.Function, er.FunctionExecution)):
|
||||
# Adjust scope: If the name is not in the suite, it's a param
|
||||
# default or annotation and will be resolved as part of the
|
||||
# parent scope.
|
||||
colon = scope.children.index(':')
|
||||
if atom.start_pos < scope.children[colon + 1].start_pos:
|
||||
scope = scope.get_parent_scope()
|
||||
if isinstance(stmt, tree.CompFor):
|
||||
stmt = stmt.get_parent_until((tree.ClassOrFunc, tree.ExprStmt))
|
||||
if stmt.type != 'expr_stmt':
|
||||
|
||||
@@ -37,7 +37,9 @@ def _evaluate_for_annotation(evaluator, annotation):
|
||||
if element is None:
|
||||
debug.warning('Annotation not parsed: %s' % definition.obj)
|
||||
else:
|
||||
element.parent = annotation.parent
|
||||
module = annotation.get_parent_until()
|
||||
p.position_modifier.line = module.end_pos[0]
|
||||
element.parent = module
|
||||
definitions |= evaluator.eval_element(element)
|
||||
else:
|
||||
definitions.add(definition)
|
||||
|
||||
Reference in New Issue
Block a user