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

Support PEP 646 syntax for Callable #15951

Merged
merged 1 commit into from
Aug 26, 2023

Conversation

ilevkivskyi
Copy link
Member

Fixes #15412

Two new things here as specified by PEP 646:

  • Using star for an (explicit) type unpaking in callables, like Callable[[str, *tuple[int, ...]], None]
  • Allowing suffix items after a variadic item, like Callable[[X, Unpack[Ys], Z], bool]

Implementation is straightforward. Btw while working in this I accidentally fixed a nasty bug, tuple types were often not given any line/column numbers, so if such type becomes a location of an error, it is impossible to ignore.

@github-actions
Copy link
Contributor

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

@ilevkivskyi
Copy link
Member Author

@JukkaL @jhance The TypeVarTuple PRs start to pile up, I am going to merge some without review to move faster (I am now working on two trickier PRs) unless you have objections.

@ilevkivskyi ilevkivskyi merged commit 29abf39 into python:master Aug 26, 2023
17 checks passed
@ilevkivskyi ilevkivskyi deleted the callable-646 branch August 26, 2023 20:30
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.

Allow Callable with a TypeVarTuple in the middle
1 participant