-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
This is a simplified example from a larger project. I've resorted to spamming Any
and avoiding the TypeVar
s for now since type is longer than the code itself 😆
import contextlib
from typing import Callable
from typing import Generator
from typing import Iterable
from typing import TypeVar
T = TypeVar('T')
T2 = TypeVar('T2')
MC = Callable[[Callable[[T2], T], Iterable[T2]], Iterable[T]]
@contextlib.contextmanager
def f() -> Generator[Callable[[Callable[[T2], T], Iterable[T2]], Iterable[T]], None, None]:
yield map
@contextlib.contextmanager
def f2() -> Generator[MC, None, None]:
yield map
I expect f
and f2
to be identical, however:
$ mypy t.py --disallow-any-generic
t.py:19: error: Missing type parameters for generic type
I can silence the error by doing:
@contextlib.contextmanager
def f2() -> Generator[MC[T2, T], None, None]:
yield map
or
@contextlib.contextmanager
def f2() -> Generator[MC[T, T2], None, None]:
yield map
but it's unclear to me what that's doing and/or why it is different
tandav
Metadata
Metadata
Assignees
Labels
No labels