From: Bryan Bugyi Date: Sat, 7 Nov 2020 00:17:23 +0000 (-0500) Subject: Fix bug which causes f-expressions to be split (#1809) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/edf1c9dc0f20239b9d5351d8b0607c9e936dd43f Fix bug which causes f-expressions to be split (#1809) Closes #1807. --- diff --git a/src/black/__init__.py b/src/black/__init__.py index e09838d..7a7456a 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -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""" - (? TMatchResult: diff --git a/tests/data/long_strings__regression.py b/tests/data/long_strings__regression.py index 9bfb1ee..7065b2f 100644 --- a/tests/data/long_strings__regression.py +++ b/tests/data/long_strings__regression.py @@ -371,6 +371,10 @@ RE_THREE_BACKSLASHES = { ), } +# 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 @@ -830,3 +834,13 @@ RE_THREE_BACKSLASHES = { r"(?