Skip to content

[pycodestyle] Document E731 fix safety - #26847

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
dwego:docs-e731-fix-safety
Jul 16, 2026
Merged

ntBre merged 2 commits into
astral-sh:mainfrom
dwego:docs-e731-fix-safety

Conversation

@dwego

@dwego dwego commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a Fix safety section to the documentation for
lambda-assignment (E731).

The new section explains that converting a lambda assignment into a function
definition changes observable callable metadata. In particular, the function's
__name__ changes from "<lambda>" to the assigned variable name, which can
affect code that relies on logging, registration, or introspection.

The E731 fix was changed from display-only to unsafe in #19700. Related
discussion: #19650.

Part of #15584.

Test Plan

  • cargo fmt --all
  • git diff --check
  • Manually verified the E731 unsafe fix and the resulting __name__ change.

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 15, 2026 08:33
Comment thread crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs Outdated
Comment thread crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs Outdated
Comment thread crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs Outdated
@ntBre ntBre added the documentation Improvements or additions to public-facing documentation label Jul 15, 2026
@ntBre ntBre changed the title [pycodestyle] Document E731 fix safety [pycodestyle] Document E731 fix safety Jul 15, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ntBre ntBre closed this Jul 16, 2026
@ntBre ntBre reopened this Jul 16, 2026
@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 16, 2026 14:03
@ntBre
ntBre merged commit fe8ba85 into astral-sh:main Jul 16, 2026
77 of 93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants