Skip to content

Conversation

njhearp
Copy link
Contributor

@njhearp njhearp commented Oct 6, 2025

Summary

Fixes #20700

else and elif blocks could previously be deleted when applying a fix for this rule. If an else or elif branch is detected the rule will not trigger. So now the rule will only flag if it is safe.

Copy link
Contributor

github-actions bot commented Oct 6, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Collaborator

@dylwil3 dylwil3 left a comment

Choose a reason for hiding this comment

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

Thank you!

@dylwil3 dylwil3 added bug Something isn't working fixes Related to suggested fixes for violations rule Implementing or modifying a lint rule and removed fixes Related to suggested fixes for violations labels Oct 6, 2025
@dylwil3 dylwil3 merged commit 1c5666c into astral-sh:main Oct 6, 2025
39 checks passed
@dylwil3 dylwil3 changed the title [RUF051] Ignore if else/elif block is present [ruff] Skip RUF051 if else/elif block is present Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RUF051] fix silently drops else branch

2 participants