Skip to content

Avoid PLW0108 for forward references#25202

Open
Sean-Kenneth-Doherty wants to merge 1 commit into
astral-sh:mainfrom
Sean-Kenneth-Doherty:codex/plw0108-forward-reference
Open

Avoid PLW0108 for forward references#25202
Sean-Kenneth-Doherty wants to merge 1 commit into
astral-sh:mainfrom
Sean-Kenneth-Doherty:codex/plw0108-forward-reference

Conversation

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Summary

  • Avoid reporting PLW0108 when inlining the lambda would evaluate a referenced callable earlier than the lambda currently does
  • Keep reporting and fixing cases where the callable binding is already available at the replacement location
  • Add fixture and snapshot coverage for module-level and local forward-reference cases

Validation

  • cargo test -p ruff_linter unnecessary_lambda
  • cargo check -p ruff_linter
  • cargo fmt --check -- crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs
  • git diff --check upstream/main...HEAD

@astral-sh-bot astral-sh-bot Bot requested a review from ntBre May 17, 2026 02:59
@Sean-Kenneth-Doherty
Copy link
Copy Markdown
Author

Local validation for fd2a5a27accb36cf9de2cfb0bb27cbc8db6e6a48:

  • cargo test -p ruff_linter unnecessary_lambda passed: the targeted PLW0108 snapshot test passed (1 passed, 2776 filtered out).
  • cargo check -p ruff_linter passed.
  • cargo fmt --check -- crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs passed.
  • git diff --check upstream/main...HEAD and git diff --check passed.
  • uvx prek run --from-ref upstream/main passed (merge conflicts, typos, and rustfmt; unrelated hooks skipped because no matching files changed).

The local checkout is clean after validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants