Closed
Description
Follow up from a discussion on gitter:
from typing import *
T = TypeVar('T')
class Factory(Generic[T]):
@classmethod
def instance(cls) -> 'Factory[T]':
return cls()
def produce(self) -> T:
raise NotImplementedError()
@classmethod
def get(cls) -> T:
return cls.instance().produce()
class HelloWorldFactory(Factory[str]):
def produce(self) -> str:
return 'Hello World'
# factory.py:25: error: Incompatible return value type (got "T", expected "str")
def error_with_mypy() -> str:
return HelloWorldFactory.get()
@ilevkivskyi mentioned this should not error and that this code is valid. I don't have the necessary context to understand how to classify this issue.