HeliWang · GitHub

For such an example:

from abc import ABCMeta, abstractmethod
from typing import Callable, Type, TypeVar, Any
class A(metaclass=ABCMeta):
    @abstractmethod
    def foo(self, x: int) -> Any: pass
    @abstractmethod
    def bar(self) -> str: pass
class B(A):
    def foo(self, x: int) -> None: ...
    def bar(self) -> int:
        return 1
#a = A()  # Error: A is abstract
b = B()  # OK

Mypy will complain the following error:
a.py:13: error: Return type of "bar" incompatible with supertype "A"

However pytype seems to ignore such an error.
Is there a way to check return type error incompatible with supertype? Thanks.

Read the original on github.com ↗