Improve detection of whether a symbol refers to a builtin exception #13215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes several minor improvements to functions in the
ruff_python_stdlib::builtins
module. It is a followup to #13172. The following changes are made:is_ipython_builtin
becomes private, andis_python_builtin
callsis_ipython_builtin
. We don't have a use case for distinguishing between IPython builtins and regular builtins, and the way we currently have the checks split into two functions seems error-prone, as you could easily forget to callis_ipython_builtin
, which would lead to incorrect results when checking a notebookis_exception
function was missing several builtin exceptions added in newer Python versions.is_exception
function take account of the Python version an exception was added in, similar to the change Use dynamic builtins list based on Python version #13172 made tois_python_builtin
.Test Plan
I added some new fixtures to the sole lint rule that uses
is_exception()
. Other than the changes to that function, the changes here aren't particularly user-facing.