Skip to content
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

Fix E251 false positive inside f-strings #7894

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Conversation

dhruvmanila
Copy link
Member

Summary

This PR fixes the bug where the rule E251 was being triggered on a equal token
inside a f-string which was used in the context of debug expressions.

For example, the following was being flagged before the fix:

print(f"{foo = }")

But, now it is not. This leads to false negatives such as:

print(f"{foo(a = 1)}")

One solution would be to know if the opened parentheses was inside a f-string or
not. If it was then we can continue flagging until it's closed. If not, then we
should not flag it.

Test Plan

Add new test cases and check that they don't raise any false positives.

fixes: #7882

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@dhruvmanila dhruvmanila added the bug Something isn't working label Oct 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

@dhruvmanila dhruvmanila enabled auto-merge (squash) October 12, 2023 05:19
@dhruvmanila dhruvmanila merged commit 4454fbf into main Oct 12, 2023
15 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/fstring-E25 branch October 12, 2023 05:26
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E251 from spaces around equals in f-string in function argument
2 participants