Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 199e3eb

Browse files
authored
Fix regular expression that black uses to identify f-expressions (psf#2287)
Fixes psf#1469
1 parent 4ca4407 commit 199e3eb

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Add extra uvloop install + import support if in python env (#2258)
1313
- Fix --experimental-string-processing crash when matching parens are not found (#2283)
1414
- Make sure to split lines that start with a string operator (#2286)
15+
- Fix regular expression that black uses to identify f-expressions (#2287)
1516

1617
### _Blackd_
1718

src/black/trans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ class StringSplitter(CustomSplitMapMixin, BaseStringSplitter):
971971
| \{\{
972972
| \}\}
973973
| (?R)
974-
)+?
975-
(?<!\}) \} (?:\}\})* (?!\})
974+
)+
975+
\}
976976
"""
977977

978978
def do_splitter_match(self, line: Line) -> TMatchResult:

tests/data/long_strings__regression.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ def _legacy_listen_examples():
407407
)
408408

409409

410+
temp_msg = (
411+
f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
412+
f"{balance: <{bal_len + 5}} "
413+
f"<<{author.display_name}>>\n"
414+
)
415+
410416
assert str(suffix_arr) == (
411417
"['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "
412418
"'grykangaroo$', 'kangaroo$', 'ngaroo$', 'ngrykangaroo$', "
@@ -942,6 +948,12 @@ def _legacy_listen_examples():
942948
)
943949

944950

951+
temp_msg = (
952+
f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
953+
f"{balance: <{bal_len + 5}} "
954+
f"<<{author.display_name}>>\n"
955+
)
956+
945957
assert (
946958
str(suffix_arr)
947959
== "['$', 'angaroo$', 'angrykangaroo$', 'aroo$', 'garoo$', "

0 commit comments

Comments
 (0)