Skip to content

Commit

Permalink
Merge pull request #1177 from PyCQA/escaped-newline-starting-fstring
Browse files Browse the repository at this point in the history
3.12: fix fstring starting with escape
  • Loading branch information
asottile committed Jul 18, 2023
2 parents 3c6f86b + 146c422 commit d8443f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2026,17 +2026,17 @@ def maybe_check_physical(self, token, prev_physical):
"""If appropriate for token, check current physical line(s)."""
# Called after every token, but act only on end of line.

if token.type == FSTRING_START: # pragma: >=3.12 cover
self.fstring_start = token.start[0]
# a newline token ends a single physical line.
if _is_eol_token(token):
elif _is_eol_token(token):
# if the file does not end with a newline, the NEWLINE
# token is inserted by the parser, but it does not contain
# the previous physical line in `token[4]`
if token.line == '':
self.check_physical(prev_physical)
else:
self.check_physical(token.line)
elif token.type == FSTRING_START: # pragma: >=3.12 cover
self.fstring_start = token.start[0]
elif (
token.type == tokenize.STRING and '\n' in token.string or
token.type == FSTRING_END
Expand Down
4 changes: 4 additions & 0 deletions testing/data/E50.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
def foo():
"""Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pulvinar vitae
"""
#: E501
loooooong = 'looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong'
f"""\
"""
#: Okay
"""
This
Expand Down

0 comments on commit d8443f8

Please sign in to comment.