Skip to content
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

Fix crash with type alias to Callable[[Unpack[Tuple[Any, ...]]], Any] #16541

Merged
merged 2 commits into from Dec 12, 2023

Conversation

AlexWaygood
Copy link
Member

Fixes #16533

This comment has been minimized.

expanded_tuple = var_arg_type.accept(self)
assert isinstance(expanded_tuple, ProperType) and isinstance(expanded_tuple, TupleType)
expanded_items = expanded_tuple.items
fallback = var_arg_type.partial_fallback
elif isinstance(var_arg_type, Instance):
# We have something like Unpack[Tuple[Any, ...]]
expanded_items = list(var_arg_type.args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we preserve this as an Instance? Are we converting a variable-length tuple to a single-item tuple?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see what you mean (I think)! Does e4d02a4 address this?

I'm surprised no tests failed as a result of this.

Copy link
Contributor

github-actions bot commented Dec 7, 2023

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@JukkaL JukkaL merged commit 5fa9569 into python:master Dec 12, 2023
18 checks passed
@AlexWaygood AlexWaygood deleted the fix-tvar-tuple-crash branch December 12, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal error with an alias type that is a callable with an unpacked tuple as args
2 participants