Skip to content

Is there a way to check return type error incompatible with supertype? #81

@HeliWang

Description

@HeliWang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions