Skip to content

Logger.getChild bad signature #6606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randolf-scholz opened this issue Dec 16, 2021 · 1 comment
Closed

Logger.getChild bad signature #6606

randolf-scholz opened this issue Dec 16, 2021 · 1 comment

Comments

@randolf-scholz
Copy link
Contributor

randolf-scholz commented Dec 16, 2021

The signature of Logger.getChild is

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

def getChild(self: T, suffix: str) -> T: ...

where T = TypeVar('T', bound=Logger). Cf. python/mypy#1212 and python/typing#980

@JelleZijlstra
Copy link
Member

Fixes in #6609

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants