Created
May 24, 2025 11:19
-
-
Save mypy-play/4c9ca727dbc78127c4934f43edfdcc00 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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
from typing import Callable, Generic, TypeVarTuple, Unpack | |
# side note: something like this syntax seems unsupported | |
# class Class[*Ts=Unpack[tuple[()]]]]: | |
Ts = TypeVarTuple("Ts", default=Unpack[tuple[()]]) | |
class Class(Generic[*Ts]): | |
def foo(self, x: Callable[[*Ts], None]) -> None: ... | |
def x_no_args() -> None: ... | |
# works as expected | |
Class().foo(x_no_args) | |
# fails | |
obj: Class = Class() | |
obj.foo(x_no_args) | |
# also fails | |
class Other: | |
obj: Class | |
Other().obj.foo(x_no_args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment