Skip to content

Commit d8443f8

Browse files
authored
Merge pull request #1177 from PyCQA/escaped-newline-starting-fstring
3.12: fix fstring starting with escape
2 parents 3c6f86b + 146c422 commit d8443f8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pycodestyle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,17 +2026,17 @@ def maybe_check_physical(self, token, prev_physical):
20262026
"""If appropriate for token, check current physical line(s)."""
20272027
# Called after every token, but act only on end of line.
20282028

2029+
if token.type == FSTRING_START: # pragma: >=3.12 cover
2030+
self.fstring_start = token.start[0]
20292031
# a newline token ends a single physical line.
2030-
if _is_eol_token(token):
2032+
elif _is_eol_token(token):
20312033
# if the file does not end with a newline, the NEWLINE
20322034
# token is inserted by the parser, but it does not contain
20332035
# the previous physical line in `token[4]`
20342036
if token.line == '':
20352037
self.check_physical(prev_physical)
20362038
else:
20372039
self.check_physical(token.line)
2038-
elif token.type == FSTRING_START: # pragma: >=3.12 cover
2039-
self.fstring_start = token.start[0]
20402040
elif (
20412041
token.type == tokenize.STRING and '\n' in token.string or
20422042
token.type == FSTRING_END

testing/data/E50.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@
9292
def foo():
9393
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pulvinar vitae
9494
"""
95+
#: E501
96+
loooooong = 'looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong'
97+
f"""\
98+
"""
9599
#: Okay
96100
"""
97101
This

0 commit comments

Comments
 (0)