mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-26 18:06:43 +00:00
|
Some checks are pending
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
This pull request fixes the bug described in issue [#19153](https://github.com/astral-sh/ruff/issues/19153). The issue occurred when `PERF403` incorrectly flagged cases involving tuple unpacking in a for loop. For example: ```python def f(): v = {} for (o, p), x in [("op", "x")]: v[x] = o, p ``` This code was wrongly suggested to be rewritten into a dictionary comprehension, which changes the semantics. Changes in this PR: Updated the `PERF403` rule to correctly handle tuple unpacking in loop targets. Added regression tests to ensure this case (and similar ones) are no longer flagged incorrectly. Why: This ensures that `PERF403` only triggers when a dictionary comprehension is semantically equivalent to the original loop, preventing false positives. --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com> |
||
|---|---|---|
| .. | ||
| resources | ||
| src | ||
| Cargo.toml | ||