Repository navigation
Avoid syntax errors for type variables with starred constraints (UP040, UP046, UP047, RUF053) - #28362
Merged
Merged
Conversation
ntBre
requested changes
Sep 8, 2026
| } | ||
|
|
||
| if non_default_follows_default(&vars) { | ||
| if non_default_follows_default(&vars) || vars.iter().any(TypeVar::has_starred_constraint) { |
Contributor
There was a problem hiding this comment.
This appears to have the same issue identified in #28232 (comment).
Contributor
Author
There was a problem hiding this comment.
yes you're right that (*constraints,) is valid. I fixed the shared formatter, removed the checks that skipped starred contraints, and added regression tests for all four rules. These fixes were also verifed on python 3.12 and 3.14.
LckyLke
force-pushed
the
fix/pep695-starred-constraints
branch
from
September 9, 2026 07:26
7737ca4 to
f8695b7
Compare
TypeVars with starred constraints (UP040, UP046, UP047, RUF053)UP040, UP046, UP047, RUF053)
ntBre
approved these changes
Oct 16, 2026
ntBre
left a comment
Contributor
There was a problem hiding this comment.
Thanks! I took care of the merge conflicts, trimmed the tests a bit, and also refactored the case with more than one element, but the fix here looked good.
|
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.
fixes #26954.
Adds the missing tuple comma so starred contraints produce valid pep 695 fixes. Existing single element constraint tuples also keep their comma.
Tests cover aliases, classes and function type paramters across all four rules. All 2828 linter tests, clippy and hooks passed. checked the fixed code on python 3.12 and 3.14.