The signature of `Logger.getChild` is ```python def getChild(self, suffix: str) -> Logger: ... ``` However, this fails if one subclasses `Logger`, e.g. the following code ``` logger = MyLogger(...) child: MyLogger = logger.getChild(...) ``` Raises `type[assignment]` error (expression has type "Logger", variable has type "MyLogger"). The signature should be ```python def getChild(self: T, suffix: str) -> T: ... ``` where `T = TypeVar('T', bound=Logger)`. Cf. https://github.com/python/mypy/issues/1212 and https://github.com/python/typing/discussions/980
Activity
JelleZijlstra commentedon Dec 22, 2021
Fixes in #6609