Skip to content

Instantly share code, notes, and snippets.

@pmeier
Created March 25, 2020 10:29
Show Gist options
  • Save pmeier/4439755ed0add02dd22eab81c5d7d34e to your computer and use it in GitHub Desktop.
Save pmeier/4439755ed0add02dd22eab81c5d7d34e to your computer and use it in GitHub Desktop.
class Foo:
def bar(self, *baz):
raise NotImplementedError
class SubFoo(Foo):
def bar(self, baz: float) -> str:
pass
from typing import Generic, TypeVar, Callable
T_co = TypeVar("T_co", covariant=True)
class Foo(Generic[T_co]):
bar: Callable[..., T_co]
class Foo:
def bar(self, *baz):
raise NotImplementedError
class SubFoo(Foo):
def bar(self, baz):
pass
from typing import Generic, TypeVar, Callable
T_co = TypeVar("T_co", covariant=True)
class Foo(Generic[T_co]):
bar: Callable[..., T_co]
class SubFoo(Foo):
bar: Callable[[float], str]
@pmeier
Copy link
Author

pmeier commented Mar 25, 2020

To reproduce the behavior from the question run

git clone https://gist.github.com/4439755ed0add02dd22eab81c5d7d34e.git tmp
cd tmp
python3.6 -m mypy succeeding.py
python3.6 -m mypy failing.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment