Created
March 25, 2020 10:29
-
-
Save pmeier/4439755ed0add02dd22eab81c5d7d34e to your computer and use it in GitHub Desktop.
Example code for https://stackoverflow.com/questions/60776671/inline-type-annotations-vs-stub-results-in-different-mypy-behaviour
This file contains 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
class Foo: | |
def bar(self, *baz): | |
raise NotImplementedError | |
class SubFoo(Foo): | |
def bar(self, baz: float) -> str: | |
pass |
This file contains 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 Generic, TypeVar, Callable | |
T_co = TypeVar("T_co", covariant=True) | |
class Foo(Generic[T_co]): | |
bar: Callable[..., T_co] |
This file contains 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
class Foo: | |
def bar(self, *baz): | |
raise NotImplementedError | |
class SubFoo(Foo): | |
def bar(self, baz): | |
pass |
This file contains 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 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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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