mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
if_stmt test clauses should be resolved at the start of the if_stmt
This commit is contained in:
@@ -288,10 +288,13 @@ def infer_atom(context, atom):
|
||||
if atom.type == 'name':
|
||||
# This is the first global lookup.
|
||||
stmt = tree.search_ancestor(
|
||||
atom, 'expr_stmt', 'lambdef'
|
||||
atom, 'expr_stmt', 'lambdef', 'if_stmt'
|
||||
) or atom
|
||||
if stmt.type == 'lambdef':
|
||||
stmt = atom
|
||||
if stmt.type == 'if_stmt':
|
||||
if not any(n.start_pos <= atom.start_pos < n.end_pos for n in stmt.get_test_nodes()):
|
||||
stmt = atom
|
||||
position = stmt.start_pos
|
||||
if _is_annotation_name(atom):
|
||||
# Since Python 3.7 (with from __future__ import annotations),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
x = 3
|
||||
if NOT_DEFINED:
|
||||
x = ''
|
||||
#? 6 int() str()
|
||||
#? 6 int()
|
||||
elif x:
|
||||
pass
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user