Skip to content

Conversation

@Jkhall81
Copy link
Contributor

@Jkhall81 Jkhall81 commented Jan 3, 2026

Summary

This PR fixes #22334 by updating the SIM105 fix to use get_or_import_builtin_symbol for BaseException.

Previously, the fix would always insert an unnecessary import builtins and use builtins.BaseException. This change ensures that BaseException is accessed directly as a builtin, only falling back to an explicit import if the name is shadowed.

Test Plan

  • Executed the specific rule test suite: cargo test -p ruff_linter rule_suppressibleexception
  • Verified the fix via snapshot diffs using cargo insta review.
  • All 5 existing SIM105 tests passed after updating snapshots.

@AlexWaygood AlexWaygood added the fixes Related to suggested fixes for violations label Jan 3, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Jan 3, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser 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

@MichaReiser MichaReiser merged commit 24580e2 into astral-sh:main Jan 5, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIM105 fix imports builtins to access BaseException

3 participants