Fix another f-string regression (#4339)
This commit is contained in:
parent
dbb956b0d3
commit
455de7703e
@ -26,6 +26,9 @@
|
||||
|
||||
<!-- Changes to the parser or to version autodetection -->
|
||||
|
||||
- Fix regression where Black failed to parse a multiline f-string containing another
|
||||
multiline string (#4339)
|
||||
|
||||
### Performance
|
||||
|
||||
<!-- Changes that improve Black's performance. -->
|
||||
|
@ -622,10 +622,10 @@ def generate_tokens(
|
||||
spos = strstart
|
||||
epos = (lnum, end)
|
||||
tokenline = contline + line
|
||||
if (
|
||||
fstring_state.current() == STATE_NOT_FSTRING
|
||||
and not is_fstring_start(token)
|
||||
):
|
||||
if fstring_state.current() in (
|
||||
STATE_NOT_FSTRING,
|
||||
STATE_IN_BRACES,
|
||||
) and not is_fstring_start(token):
|
||||
yield (STRING, token, spos, epos, tokenline)
|
||||
endprog_stack.pop()
|
||||
parenlev = parenlev_stack.pop()
|
||||
|
@ -125,6 +125,9 @@
|
||||
|
||||
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
||||
|
||||
f"""{'''
|
||||
'''}"""
|
||||
|
||||
# output
|
||||
|
||||
x = f"foo"
|
||||
@ -252,3 +255,6 @@
|
||||
f"{1:{2}d}"
|
||||
|
||||
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
||||
|
||||
f"""{'''
|
||||
'''}"""
|
||||
|
Loading…
Reference in New Issue
Block a user