Skip to content

Logger.getChild bad signature #6606

Closed
Closed

Description

@randolf-scholz

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

Activity

  1. JelleZijlstra commented on Dec 22, 2021

    @JelleZijlstra
    Member

    Fixes in #6609

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions