From 5e7ff808d495b3f13396ea012be175de9f52a5b9 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 23 Dec 2018 15:32:22 +0100 Subject: [PATCH] Fix f-string evaluation, fixes #1248 --- jedi/evaluate/syntax_tree.py | 4 +++- test/completion/fstring.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/syntax_tree.py b/jedi/evaluate/syntax_tree.py index 6d08c5a9..8ef5697b 100644 --- a/jedi/evaluate/syntax_tree.py +++ b/jedi/evaluate/syntax_tree.py @@ -69,7 +69,7 @@ def eval_node(context, element): debug.dbg('eval_node %s@%s in %s', element, element.start_pos, context) evaluator = context.evaluator 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) elif typ == 'lambdef': return ContextSet([FunctionContext.from_context(context, element)]) @@ -221,6 +221,8 @@ def eval_atom(context, atom): right = eval_atom(context, string) context_set = _eval_comparison(context.evaluator, context, context_set, u'+', right) return context_set + elif atom.type == 'fstring': + return compiled.get_string_context_set(context.evaluator) else: c = atom.children # Parentheses without commas are not tuples. diff --git a/test/completion/fstring.py b/test/completion/fstring.py index 97cc1cc0..32f29e9b 100644 --- a/test/completion/fstring.py +++ b/test/completion/fstring.py @@ -32,3 +32,7 @@ f'xyz'.uppe #? 3 [] f'f' + +# Github #1248 +#? int() +{"foo": 1}[f"foo"]