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 new rule PERF402 suggests to convert lists to trivial copies in cases where it's not really possible. Ideally the tool would not report such false positives.
If you're filing a bug report, please consider including the following information:
A minimal code snippet that reproduces the bug.
# In this example you can't trivially convert this to a `list.copy` as the rule suggests. forrinrecord_dict["values"]:
list_of_stuff[r["other_value"]].append(r)
The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.
ruff --select=PERF402 example.py
The current Ruff settings (any relevant sections from your pyproject.toml).
PERF ruleset is enabled
The current Ruff version (ruff --version).
version = 0.0.276
The text was updated successfully, but these errors were encountered:
Makes sense, we should probably require that the left-hand side expression is a static name (or at least an expression that doesn't depend on the iteration key). Thanks!
## Summary
We need to avoid raising "rewrite as a comprehension" violations in
cases like:
```python
d = defaultdict(list)
for i in [1, 2, 3]:
d[i].append(i**2)
```
Closes#5494.
Closes#5500.
The new rule PERF402 suggests to convert lists to trivial copies in cases where it's not really possible. Ideally the tool would not report such false positives.
If you're filing a bug report, please consider including the following information:
The command you invoked (e.g.,
ruff /path/to/file.py --fix
), ideally including the--isolated
flag.ruff --select=PERF402 example.py
The current Ruff settings (any relevant sections from your
pyproject.toml
).PERF
ruleset is enabledThe current Ruff version (
ruff --version
).version =
0.0.276
The text was updated successfully, but these errors were encountered: