-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 F541
to use new tokens to detect f-strings
#7292
Comments
dhruvmanila
added
python312
Related to Python 3.12
rule
Implementing or modifying a lint rule
labels
Sep 12, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 18, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 19, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 20, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 21, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 22, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 26, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 27, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 28, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 29, 2023
dhruvmanila
added a commit
that referenced
this issue
Sep 29, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
F541
checks for useless f-strings i.e., f-strings without any placeholders.The rule needs to be updated to use the new f-string tokens to detect that.
Possible solution
Once we encounter the
FStringStart
token and if there are no placeholders inside the f-string, then the next token is guaranteed going to aFStringMiddle
token containing the entire content of the f-string and then we'll get theFStringEnd
token. For example,f"we're inside a f-string"
The above code will emit the following tokens:
And, for triple-quoted f-strings:
We get the following tokens:
I propose to create two edits:
FStringStart
tokenFStringMiddle
token i.e., replacing{{
and}}
with{
and}
The text was updated successfully, but these errors were encountered: