Created
May 6, 2020 18:54
-
-
Save Spindel/9d5791f0f053f52009e0b50d68c752eb to your computer and use it in GitHub Desktop.
Mypy complains
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
import abc | |
import typing | |
import dataclasses | |
from functools import singledispatchmethod | |
@dataclasses.dataclass | |
class Root: | |
pass | |
@dataclasses.dataclass | |
class Child(Root): | |
name: str | |
@dataclasses.dataclass | |
class Parent(Child): | |
family: int | |
class Interface(metaclass=abc.ABCMeta): | |
@abc.abstractmethod | |
def handle(self, thing: Root) -> None: | |
raise NotImplementedError | |
class Implementer(Interface): | |
@singledispatchmethod | |
def handle(self, thing: Root) -> None: | |
raise ValueError | |
@singledispatchmethod | |
def _handle_child(self, thing: Child) -> None: | |
print("ok", thing) | |
@singledispatchmethod | |
def _handle_parent(self, thing: Parent) -> None: | |
print("ok", thing) |
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
mypy mytest.py | |
mytest.py:32: error: Signature of "handle" incompatible with supertype "Interface" | |
Found 1 error in 1 file (checked 1 source file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment