-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
coreRelated to core functionalityRelated to core functionalitypython312Related to Python 3.12Related to Python 3.12
Description
The Indexer needs to be updated to use the new f-string tokens to compute the following ranges:
- F-string ranges
- Triple-quoted string ranges
The f-string ranges (1) can be computed using the start range of a FStringStart token to the end range of a FStringEnd token. Here, a stack would probably be required as f-strings can be nested and we need to pick up the correct start value for the current end value. It would be similar to computing the ranges of parentheses pair in (foo, (bar, baz), another, (start, (nested, done), nope), last).
A FStringStart/FStringEnd token consists of prefixes (f, fr, etc.) and quotes. Using this information we can detect if a f-string is tripled-quoted or not using either of the following proposed solutions:
- Using the
Locator, we can extract out the source for theFStringStarttoken using the token range, extract the quotes usingleading_quoteand use the.text_lenmethod to check the number of quotes. - We can store additional information in the
FStringStarttoken itself in the form of bitflags or boolean values similar toFStringMiddle. This can then be used to check if it's a tripled-quoted f-string or not.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreRelated to core functionalityRelated to core functionalitypython312Related to Python 3.12Related to Python 3.12