Repository navigation
[pyupgrade] Clarify UP029 as a Python 2 compatibility rule - #26243
Merged
Merged
Conversation
…#21148) The existing docs describe UP029 as catching unnecessary builtin imports in general, but the rule only fires on a fixed set of Python 2 / Python 3 compatibility imports (from `builtins`, `io.open`, `six`, and `six.moves`). Reword "What it does" and "Why is this bad?" to match. The violation message and rule logic are unchanged. Closes astral-sh#21148.
ntBre
reviewed
Jun 22, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Thanks! This looks good overall, just one clarification on the source of builtins and io, as I understand it.
pyupgrade] Clarify UP029 as a Python 2 compatibility rule
Contributor
Author
|
Good catch, thanks! You're right. Verified that |
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi! Small intro contribution to ruff #21148.
The current UP029 docs read like the rule catches any import of a builtin (e.g.
from builtins import tuple), but the rule only fires on a fixed allowlist of Python 2 / Python 3 compatibility imports frombuiltins,io.open,six, andsix.moves. The issue reporter pointed this out and matches what the upstream pyupgrade rule was originally designed for.Scope is just the
## What it doesand## Why is this bad?doc comments. Violation message, example, fix, and rule logic are untouched, so no snapshots move.Hand-wrote the PR summary per the AI policy.
Closes #21148.