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 -->
|
<!-- 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
|
### Performance
|
||||||
|
|
||||||
<!-- Changes that improve Black's performance. -->
|
<!-- Changes that improve Black's performance. -->
|
||||||
|
@ -622,10 +622,10 @@ def generate_tokens(
|
|||||||
spos = strstart
|
spos = strstart
|
||||||
epos = (lnum, end)
|
epos = (lnum, end)
|
||||||
tokenline = contline + line
|
tokenline = contline + line
|
||||||
if (
|
if fstring_state.current() in (
|
||||||
fstring_state.current() == STATE_NOT_FSTRING
|
STATE_NOT_FSTRING,
|
||||||
and not is_fstring_start(token)
|
STATE_IN_BRACES,
|
||||||
):
|
) and not is_fstring_start(token):
|
||||||
yield (STRING, token, spos, epos, tokenline)
|
yield (STRING, token, spos, epos, tokenline)
|
||||||
endprog_stack.pop()
|
endprog_stack.pop()
|
||||||
parenlev = parenlev_stack.pop()
|
parenlev = parenlev_stack.pop()
|
||||||
|
@ -125,6 +125,9 @@
|
|||||||
|
|
||||||
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
||||||
|
|
||||||
|
f"""{'''
|
||||||
|
'''}"""
|
||||||
|
|
||||||
# output
|
# output
|
||||||
|
|
||||||
x = f"foo"
|
x = f"foo"
|
||||||
@ -252,3 +255,6 @@
|
|||||||
f"{1:{2}d}"
|
f"{1:{2}d}"
|
||||||
|
|
||||||
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
f'{{\\"kind\\":\\"ConfigMap\\",\\"metadata\\":{{\\"annotations\\":{{}},\\"name\\":\\"cluster-info\\",\\"namespace\\":\\"amazon-cloudwatch\\"}}}}'
|
||||||
|
|
||||||
|
f"""{'''
|
||||||
|
'''}"""
|
||||||
|
Loading…
Reference in New Issue
Block a user