Infer list[T] for starred target in unpacking#18401
Merged
dhruvmanila merged 1 commit intomainfrom Jun 3, 2025
Merged
Conversation
Contributor
|
3092eda to
3e81edc
Compare
dhruvmanila
added a commit
that referenced
this pull request
Jun 3, 2025
## Summary Follow-up from #18401, I was looking at whether that would fix the issue at astral-sh/ty#247 (comment) and it didn't, which made me realize that the PR only inferred `list[T]` when the value type was tuple but it could be other types as well. This PR fixes the actual issue by inferring `list[T]` for the non-tuple type case. ## Test Plan Add test cases for starred expression involved with non-tuple type. I also added a few test cases for list type and list literal. I also verified that the example in the linked issue comment works: ```py def _(line: str): a, b, *c = line.split(maxsplit=2) c.pop() ```
dcreager
added a commit
that referenced
this pull request
Jun 3, 2025
…aration * origin/main: [ty] Infer `list[T]` when unpacking non-tuple type (#18438) [ty] Meta-type of type variables should be type[..] (#18439) [`pyupgrade`] Make fix unsafe if it deletes comments (`UP050`) (#18390) [`pyupgrade`] Make fix unsafe if it deletes comments (`UP004`) (#18393) [ty] Support using legacy typing aliases for generic classes in type annotations (#18404) Use ty's completions in playground (#18425) Update editor setup docs about Neovim and Vim (#18324) Update NPM Development dependencies (#18423) Infer `list[T]` for starred target in unpacking (#18401) [`refurb`] Mark `FURB180` fix unsafe when class has bases (#18149) [`fastapi`] Avoid false positive for class dependencies (`FAST003`) (#18271)
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.
Summary
Closes: astral-sh/ty#191
Test Plan
Update existing tests.