- 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:
|
# 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?
https://github.com/python/mypy/tree/103f5f3ec3fcc8fba429edcc4ee61c1370153ff9
Reporting a bug
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:
No error is reported
The definition of
Baz.do_stuff()accepts astr, which is incompatible withBar.do_stuff()'s abstract method definition (which acceptsUnion[str, int]).This bug appears to be related to the following TODO comment:
mypy/mypy/checker.py
Line 1634 in d1c8f27
Interestingly, if I reverse the order of
FooandBarinBaz's base class list, mypy reports the error.Do you see the same issue after installing mypy from Git master?
https://github.com/python/mypy/tree/103f5f3ec3fcc8fba429edcc4ee61c1370153ff9