-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I was running ruff on Sympy, applied the experimental ruff PERF rules and hit a bug. When running it on this file at this commit:
https://github.com/sympy/sympy/blob/b3d060459054d0cbd925a06fc7719a6f3b498a91/sympy/polys/galoistools.py#L1812 it recommends removing the list cast, but one can't do that because the inner while loop modifies the list that it is iterating over leading to an error. I tried to extract a smaller reproducer out of this, but was unable to.
version used: ruff 0.2.0
ruff --select PERF --show-source --fix file.py leads to the invalid fix.
sympy/polys/galoistools.py:1812:18: PERF101 [*] Do not cast an iterable to `list` before iterating over it
|
1811 | for k in range(1, len(V)):
1812 | for f in list(factors):
| ^^^^^^^^^^^^^ PERF101
1813 | s = K.zero
|
= help: Remove `list()` cast
worse, this is a safe fix and it makes the file invalid.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working