-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Indexer
to use new tokens to compute the ranges
#7290
Comments
dhruvmanila
added
rule
Implementing or modifying a lint rule
python312
Related to Python 3.12
core
Related to core functionality
and removed
rule
Implementing or modifying a lint rule
labels
Sep 12, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 19, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 20, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 21, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 26, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 27, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 28, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 29, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
dhruvmanila
added a commit
that referenced
this issue
Sep 29, 2023
## Summary This PR updates the `Indexer` to use the new f-string tokens to compute the `f_string_ranges` for f-strings. It adds a new abstraction which exposes two methods to support extracting the range for the surrounding innermost and outermost f-string. It uses the builder pattern to build the f-string ranges which is similar to how the comment ranges are built. ## Test Plan Add new test cases for f-strings for: * Tab indentation rule * Line continuation detection in the indexer * To get the innermost / outermost f-string range * All detected f-string ranges fixes: #7290
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
Indexer
needs to be updated to use the new f-string tokens to compute the following ranges:The f-string ranges (1) can be computed using the start range of a
FStringStart
token to the end range of aFStringEnd
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:Locator
, we can extract out the source for theFStringStart
token using the token range, extract the quotes usingleading_quote
and use the.text_len
method to check the number of quotes.FStringStart
token 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.The text was updated successfully, but these errors were encountered: