mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +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':
|
if atom.type == 'name':
|
||||||
# This is the first global lookup.
|
# This is the first global lookup.
|
||||||
stmt = tree.search_ancestor(
|
stmt = tree.search_ancestor(
|
||||||
atom, 'expr_stmt', 'lambdef'
|
atom, 'expr_stmt', 'lambdef', 'if_stmt'
|
||||||
) or atom
|
) or atom
|
||||||
if stmt.type == 'lambdef':
|
if stmt.type == 'lambdef':
|
||||||
stmt = atom
|
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
|
position = stmt.start_pos
|
||||||
if _is_annotation_name(atom):
|
if _is_annotation_name(atom):
|
||||||
# Since Python 3.7 (with from __future__ import annotations),
|
# Since Python 3.7 (with from __future__ import annotations),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
x = 3
|
x = 3
|
||||||
if NOT_DEFINED:
|
if NOT_DEFINED:
|
||||||
x = ''
|
x = ''
|
||||||
#? 6 int() str()
|
#? 6 int()
|
||||||
elif x:
|
elif x:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user