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
Yeah there's no autofix, I was trying to say a possible solution is just doing an autofix.
Does this clarify? It's that what the PERF401 docs suggest in this case is a SyntaxError:
my_list= []
forelementinmy_list:
ifwalrus_element:=element:
my_list.append(walrus_element)
# What ruff's PERF401 docs say, which leads to: SyntaxError: invalid syntaxmy_list= [
walrus_elementforelementinmy_listifwalrus_element:=element
]
# What you actually need to do is know this parenthesis trickmy_list= [
walrus_elementforelementinmy_listif (walrus_element:=element)
]
With this code:
ruff==0.6.7
's PERF401 errors like so:PERF401 Use a list comprehension to create a transformed list
However, due to the walrus operator (also see #6056), the fix involves putting parenthesis around the walrus.
This is just confusing enough that at first one thinks it's a PERF401 false positive. The request here is to either:
The text was updated successfully, but these errors were encountered: