Closed
Description
When I check this with mypy 0.711:
from typing import Callable, Optional
class Base:
formatter1: Callable[[int], str]
formatter2: Optional[Callable[[int], str]]
formatter3: Optional[Callable[[int], str]]
formatter4: Optional[Callable[[int], str]]
class Sub(Base):
@staticmethod
def formatter1(value: int) -> str:
return str(value)
@staticmethod
def formatter2(value: int) -> str:
return str(value)
formatter3 = formatter2
formatter4 = str
It reports:
14: error: Signature of "formatter2" incompatible with supertype "Base"
I would expect all four formatters to be accepted, but for some reason formatter2
is not.
It doesn't make a difference whether I use the old or new semantic analyzer.