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
The autofix for PLW3301 generates incorrect code if the nested call is using a generator expression.
Example
PLW3301.py:
x=max(1, max(iforiinrange(10)))
Observed
ruff --isolated --diff --select PLW3301 PLW3301.py
--- PLW3301.py
+++ PLW3301.py
@@ -1 +1 @@
-x = max(1, max(i for i in range(10)))
+x = max(1, (i for i in range(10)))
Would fix 1 error.
python -c "max(1, (i for i in range(10)))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: '>' not supported between instances of 'generator' and 'int'
Expected
The correct fix would be:
max(1, *(i for i in range(10)))
Ruff Version
ruff --version
ruff 0.0.267
The text was updated successfully, but these errors were encountered:
The autofix for
PLW3301
generates incorrect code if the nested call is using a generator expression.Example
PLW3301.py:
Observed
Issue
This is incorrect.
max
takes either an iterable, or a variable number of arguments, but not both:Expected
The correct fix would be:
Ruff Version
The text was updated successfully, but these errors were encountered: