Skip to content

Commit 5f24f6d

Browse files
committed
3.12: handle multiline FSTRING_MIDDLE
1 parent 2326e16 commit 5f24f6d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pycodestyle.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,10 @@ def maybe_check_physical(self, token, prev_physical):
21192119
self.check_physical(prev_physical)
21202120
else:
21212121
self.check_physical(token[4])
2122-
elif token[0] == tokenize.STRING and '\n' in token[1]:
2122+
elif (
2123+
token[0] in {tokenize.STRING, FSTRING_MIDDLE} and
2124+
'\n' in token[1]
2125+
):
21232126
# Less obviously, a string that contains newlines is a
21242127
# multiline string, either triple-quoted or with internal
21252128
# newlines backslash-escaped. Check every physical line in

testsuite/E50.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
#: E501 W505
7070
'''same thing, but this time without a terminal newline in the string
7171
long long long long long long long long long long long long long long long long line'''
72+
#: E501
73+
if True:
74+
x = f"""
75+
covdefaults>=1.2; python_version == '2.7' or python_version == '{py_ver}'
76+
"""
7277
#
7378
# issue 224 (unavoidable long lines in docstrings)
7479
#: Okay

0 commit comments

Comments
 (0)