mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Fix f-string evaluation, fixes #1248
This commit is contained in:
@@ -69,7 +69,7 @@ def eval_node(context, element):
|
|||||||
debug.dbg('eval_node %s@%s in %s', element, element.start_pos, context)
|
debug.dbg('eval_node %s@%s in %s', element, element.start_pos, context)
|
||||||
evaluator = context.evaluator
|
evaluator = context.evaluator
|
||||||
typ = element.type
|
typ = element.type
|
||||||
if typ in ('name', 'number', 'string', 'atom', 'strings', 'keyword'):
|
if typ in ('name', 'number', 'string', 'atom', 'strings', 'keyword', 'fstring'):
|
||||||
return eval_atom(context, element)
|
return eval_atom(context, element)
|
||||||
elif typ == 'lambdef':
|
elif typ == 'lambdef':
|
||||||
return ContextSet([FunctionContext.from_context(context, element)])
|
return ContextSet([FunctionContext.from_context(context, element)])
|
||||||
@@ -221,6 +221,8 @@ def eval_atom(context, atom):
|
|||||||
right = eval_atom(context, string)
|
right = eval_atom(context, string)
|
||||||
context_set = _eval_comparison(context.evaluator, context, context_set, u'+', right)
|
context_set = _eval_comparison(context.evaluator, context, context_set, u'+', right)
|
||||||
return context_set
|
return context_set
|
||||||
|
elif atom.type == 'fstring':
|
||||||
|
return compiled.get_string_context_set(context.evaluator)
|
||||||
else:
|
else:
|
||||||
c = atom.children
|
c = atom.children
|
||||||
# Parentheses without commas are not tuples.
|
# Parentheses without commas are not tuples.
|
||||||
|
|||||||
@@ -32,3 +32,7 @@ f'xyz'.uppe
|
|||||||
|
|
||||||
#? 3 []
|
#? 3 []
|
||||||
f'f'
|
f'f'
|
||||||
|
|
||||||
|
# Github #1248
|
||||||
|
#? int()
|
||||||
|
{"foo": 1}[f"foo"]
|
||||||
|
|||||||
Reference in New Issue
Block a user