Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve detection of whether a symbol refers to a builtin exception #13215

Merged
merged 3 commits into from
Sep 3, 2024

Conversation

AlexWaygood
Copy link
Member

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, and is_python_builtin calls is_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 call is_ipython_builtin, which would lead to incorrect results when checking a notebook
  • The is_exception function was missing several builtin exceptions added in newer Python versions.
  • I made the 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 to is_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.

@AlexWaygood AlexWaygood added the linter Related to the linter label Sep 2, 2024
Copy link
Contributor

github-actions bot commented Sep 2, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link

codspeed-hq bot commented Sep 2, 2024

CodSpeed Performance Report

Merging #13215 will not alter performance

Comparing alex/stdlib-fns (ae8d6bd) with main (9d51706)

Summary

✅ 32 untouched benchmarks

crates/ruff_python_stdlib/src/builtins.rs Outdated Show resolved Hide resolved
@AlexWaygood AlexWaygood enabled auto-merge (squash) September 3, 2024 10:30
@AlexWaygood AlexWaygood merged commit 387af83 into main Sep 3, 2024
17 checks passed
@AlexWaygood AlexWaygood deleted the alex/stdlib-fns branch September 3, 2024 10:33
@dhruvmanila dhruvmanila added the internal An internal refactor or improvement label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement linter Related to the linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants