-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use dynamic builtins list based on Python version #13172
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ke8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs | ||
--- | ||
A004.py:1:16: A004 Import `sum` is shadowing a Python builtin | ||
| | ||
1 | import some as sum | ||
| ^^^ A004 | ||
2 | import float | ||
3 | from some import other as int | ||
| | ||
|
||
A004.py:2:8: A004 Import `float` is shadowing a Python builtin | ||
| | ||
1 | import some as sum | ||
2 | import float | ||
| ^^^^^ A004 | ||
3 | from some import other as int | ||
4 | from some import input, exec | ||
| | ||
|
||
A004.py:3:27: A004 Import `int` is shadowing a Python builtin | ||
| | ||
1 | import some as sum | ||
2 | import float | ||
3 | from some import other as int | ||
| ^^^ A004 | ||
4 | from some import input, exec | ||
5 | from directory import new as dir | ||
| | ||
|
||
A004.py:4:18: A004 Import `input` is shadowing a Python builtin | ||
| | ||
2 | import float | ||
3 | from some import other as int | ||
4 | from some import input, exec | ||
| ^^^^^ A004 | ||
5 | from directory import new as dir | ||
| | ||
|
||
A004.py:4:25: A004 Import `exec` is shadowing a Python builtin | ||
| | ||
2 | import float | ||
3 | from some import other as int | ||
4 | from some import input, exec | ||
| ^^^^ A004 | ||
5 | from directory import new as dir | ||
| | ||
|
||
A004.py:5:30: A004 Import `dir` is shadowing a Python builtin | ||
| | ||
3 | from some import other as int | ||
4 | from some import input, exec | ||
5 | from directory import new as dir | ||
| ^^^ A004 | ||
6 | | ||
7 | # See: https://github.com/astral-sh/ruff/issues/13037 | ||
| |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use case (when checking a Jupyter notebook) for distinguishing between Python builtins and IPython builtins? Since we're refactoring the
is_python_builtin
function anyway, should we just make it a function that also accepts thePySourceType
as well as the Python minor version? (And get rid of theis_ipython_builtin
function?)It seems less error-prone: currently you have to remember to call both functions if you want to know if a symbol is a builtin symbol in a notebook file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think the motivation here is that the builtins check is in
uv_python_stdlib
which doesn't depend onPySourceType
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. You could probably just do it with a boolean
include_ipython_builtins
parameter... but also this doesn't need to be done in this PR!