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

Allow Callable with a TypeVarTuple in the middle #15412

Closed
ilevkivskyi opened this issue Jun 10, 2023 · 0 comments · Fixed by #15951
Closed

Allow Callable with a TypeVarTuple in the middle #15412

ilevkivskyi opened this issue Jun 10, 2023 · 0 comments · Fixed by #15951
Labels
feature priority-1-normal topic-pep-646 PEP 646 (TypeVarTuple, Unpack)

Comments

@ilevkivskyi
Copy link
Member

PEP 646 explicitly allows Callable[[T, *Ts, S], int], but mypy currently prohibits it with an error like "Positional arg cannot follow var arg". I think we should support this.

@ilevkivskyi ilevkivskyi added feature priority-1-normal topic-pep-646 PEP 646 (TypeVarTuple, Unpack) labels Jun 10, 2023
ilevkivskyi added a commit that referenced this issue Aug 26, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature priority-1-normal topic-pep-646 PEP 646 (TypeVarTuple, Unpack)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant