You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Ruff version 0.0.292, ruff --preview --isolated will misinterpret spaces around equals in f-strings that are function arguments as spaces around keyword arguments and raise an error.
a=1b=f"{a=}"# This is fineprint(a=1) # Expected E251 Unexpected spaces around keyword / parameter equalsprint(f"{a=}") # Unexpected E251
The text was updated successfully, but these errors were encountered:
Ruff currently has a bug astral-sh/ruff#7882 that means spaces in
f-strings are sometimes interpretted as spaces around keyword arguments.
This silences the error until it is fixed.
## 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:
```python
print(f"{foo = }")
```
But, now it is not. This leads to false negatives such as:
```python
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
On Ruff version 0.0.292,
ruff --preview --isolated
will misinterpret spaces around equals in f-strings that are function arguments as spaces around keyword arguments and raise an error.The text was updated successfully, but these errors were encountered: