mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-27 23:51:26 +08:00
Fix an issue with f-strings, fixes #1224
This commit is contained in:
@@ -105,14 +105,17 @@ def get_stack_at_position(grammar, code_lines, module_node, pos):
|
|||||||
# TODO This is for now not an official parso API that exists purely
|
# TODO This is for now not an official parso API that exists purely
|
||||||
# for Jedi.
|
# for Jedi.
|
||||||
tokens = grammar._tokenize(code)
|
tokens = grammar._tokenize(code)
|
||||||
for token_ in tokens:
|
for token in tokens:
|
||||||
if token_.string == safeword:
|
if token.string == safeword:
|
||||||
raise EndMarkerReached()
|
raise EndMarkerReached()
|
||||||
elif token_.prefix.endswith(safeword):
|
elif token.prefix.endswith(safeword):
|
||||||
# This happens with comments.
|
# This happens with comments.
|
||||||
raise EndMarkerReached()
|
raise EndMarkerReached()
|
||||||
|
elif token.string.endswith(safeword):
|
||||||
|
yield token # Probably an f-string literal that was not finished.
|
||||||
|
raise EndMarkerReached()
|
||||||
else:
|
else:
|
||||||
yield token_
|
yield token
|
||||||
|
|
||||||
# The code might be indedented, just remove it.
|
# The code might be indedented, just remove it.
|
||||||
code = dedent(_get_code_for_stack(code_lines, module_node, pos))
|
code = dedent(_get_code_for_stack(code_lines, module_node, pos))
|
||||||
|
|||||||
@@ -28,3 +28,7 @@ Fr'''sasdf''' + ''
|
|||||||
|
|
||||||
#? ['upper']
|
#? ['upper']
|
||||||
f'xyz'.uppe
|
f'xyz'.uppe
|
||||||
|
|
||||||
|
|
||||||
|
#? 3 []
|
||||||
|
f'f'
|
||||||
|
|||||||
Reference in New Issue
Block a user