Repository navigation
chore: Turn on all pyupgrade lints in ruff - #3360
Merged
Merged
Conversation
|
No actionable comments were generated in the recent review. Summary
Change: Other Merge Risk:
|
Contributor
|
juenglin
approved these changes
Nov 4, 2026
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.
Currently in our ruff configuration, we enable all of the lints that come from
pyupgrade(UPprefix) and then disable 3 specific rules in order to be backward compatible with the older Pythons that we still support. (pyupgradeis designed to help you upgrade your code to newer Python features, move off of deprecated things etc.) However, theUPchecks inruffare designed to automatically follow thetarget-version(currently set to3.11in our config) and automatically disable any lints that require a newer version of Python, so we should not be explicitly disabling rules.The changes this introduces fall into these categories. Mostly these are performance improvements (though not necessarily in hot loops) -- but it's nice to have the lints in place to catch this kind of thing in hot loops in the future.
Star expansion
This is a performance improvement because it avoids Python looping.
Favoring
collectionsovertypingThis isn't strictly necessary, but it prepares us for a future when the
typingaliases are deprecated..format()with no argumentsThis one detected a bona-fide bug -- that we were not interpolating a value into the message string. Only in an example, and in an error case, but still, always nice when a lint finds a real problem.
Use
yield fromThis is another performance improvement (avoids a Python loop).
Use built-ins as type annotations
This is purely a syntactic convenience.