Loading src/black/__init__.py +3 −2 Changes for src/black/__init__.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3611,13 +3611,14 @@ class StringSplitter(CustomSplitMapMixin, BaseStringSplitter): MIN_SUBSTR_SIZE = 6 # Matches an "f-expression" (e.g. {var}) that might be found in an f-string. RE_FEXPR = r""" (?<!\{)\{ (?<!\{) (?:\{\{)* \{ (?!\{) (?: [^\{\}] | \{\{ | \}\} | (?R) )+? (?<!\})(?:\}\})*\}(?!\}) (?<!\}) \} (?:\}\})* (?!\}) """ def do_splitter_match(self, line: Line) -> TMatchResult: Loading tests/data/long_strings__regression.py +14 −0 Changes for tests/data/long_strings__regression.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -371,6 +371,10 @@ def xxxxxxx_xxxxxx(xxxx): ), } # We do NOT split on f-string expressions. print(f"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam. {[f'{i}' for i in range(10)]}") x = f"This is a long string which contains an f-expr that should not split {{{[i for i in range(5)]}}}." # output Loading Loading @@ -830,3 +834,13 @@ def xxxxxxx_xxxxxx(xxxx): r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))" ), } # We do NOT split on f-string expressions. print( "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam." f" {[f'{i}' for i in range(10)]}" ) x = ( "This is a long string which contains an f-expr that should not split" f" {{{[i for i in range(5)]}}}." ) Loading
src/black/__init__.py +3 −2 Changes for src/black/__init__.py: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -3611,13 +3611,14 @@ class StringSplitter(CustomSplitMapMixin, BaseStringSplitter): MIN_SUBSTR_SIZE = 6 # Matches an "f-expression" (e.g. {var}) that might be found in an f-string. RE_FEXPR = r""" (?<!\{)\{ (?<!\{) (?:\{\{)* \{ (?!\{) (?: [^\{\}] | \{\{ | \}\} | (?R) )+? (?<!\})(?:\}\})*\}(?!\}) (?<!\}) \} (?:\}\})* (?!\}) """ def do_splitter_match(self, line: Line) -> TMatchResult: Loading
tests/data/long_strings__regression.py +14 −0 Changes for tests/data/long_strings__regression.py: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -371,6 +371,10 @@ def xxxxxxx_xxxxxx(xxxx): ), } # We do NOT split on f-string expressions. print(f"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam. {[f'{i}' for i in range(10)]}") x = f"This is a long string which contains an f-expr that should not split {{{[i for i in range(5)]}}}." # output Loading Loading @@ -830,3 +834,13 @@ def xxxxxxx_xxxxxx(xxxx): r"(?<!([0-9]\ ))(?<=(^|\ ))([A-Z]+(\ )?|[0-9](\ )|[a-z](\\\ )){4,7}([A-Z]|[0-9]|[a-z])($|\b)(?!(\ ?([0-9]\ )|(\.)))" ), } # We do NOT split on f-string expressions. print( "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam." f" {[f'{i}' for i in range(10)]}" ) x = ( "This is a long string which contains an f-expr that should not split" f" {{{[i for i in range(5)]}}}." )