Replies: 1 comment 3 replies
-
I think this will be possible with PEP 646: from typing import Callable, TypeVar, TypeVarTuple
Ts = TypeVarTuple("Ts")
T = TypeVar("T")
def outer(callback: Callable[[*Ts], T], args: tuple[*Ts]) -> T:
return callback(*args)
def inner(x: int, y: int) -> int:
return x + y
assert 3 == outer(inner, (1, "2")) Mypy does not yet support PEP 646, however. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following code, which type checks even when using
mypy --strict
:How can I type the function
outer
in a way that will fail type checking in this case?Beta Was this translation helpful? Give feedback.
All reactions