Skip to content

Update FormatStringContinuation to use the new f-string tokens #7517

@dhruvmanila

Description

@dhruvmanila

The FormatStringContinuation implementation uses the full lexer for comment handling. It expects only a limited set of tokens (String, Newline, NonLogicalNewline, Comment, Indent, Dedent) which is expected given that the lexing is performed only on the string literals.

Now, with PEP 701, the f-string literal will instead emit FStringStart, FStringMiddle, and FStringEnd. Not only that, it'll also emit other tokens for the expression part of the f-string. This poses a challenge as currently it panics for any unexpected token encountered:

token => unreachable!("Unexpected token {token:?}"),

Metadata

Metadata

Assignees

Labels

formatterRelated to the formatterpython312Related to Python 3.12

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions