-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides
Description
- Are you reporting a bug, or opening a feature request?
Reporting a bug
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
Minimal repro:
from abc import ABCMeta, abstractmethod
from typing import Generic, TypeVar, Union
A = TypeVar('A')
class Base(Generic[A]):
__metaclass__ = ABCMeta
@abstractmethod
def do_stuff(self, a):
# type: (A) -> None
pass
class Foo(Generic[A], Base[A]):
pass
class Bar(Generic[A], Base[A]):
pass
class Baz(Foo[str], Bar[Union[str, int]]):
def do_stuff(self, a):
# type: (str) -> None
return None
- What is the actual behavior/output?
No error is reported
- What is the behavior/output you expect?
The definition of Baz.do_stuff() accepts a str, which is incompatible with Bar.do_stuff()'s abstract method definition (which accepts Union[str, int]).
This bug appears to be related to the following TODO comment:
Line 1634 in d1c8f27
| # TODO: What if some classes are generic? |
Interestingly, if I reverse the order of Foo and Bar in Baz's base class list, mypy reports the error.
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
msullivan
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides