Closed
Description
With the following code:
class ContextLoggingAdapter(logging.LoggerAdapter):
def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]:
...
mypy raises the following type-arg
error : error: Missing type parameters for generic type "LoggerAdapter"
According to this type stub it's typed as a generic and should be passed the type of the logger it's an adapter for. However, changing the code into this:
class ContextLoggingAdapter(logging.LoggerAdapter[logging.Logger]):
def process(self, msg: str, kwargs: Any) -> Tuple[str, Any]:
...
makes mypy happy but raises an error at runtime: TypeError: 'type' object is not subscriptable
I'm not sure if this is an issue with the stubs or with mypy (and I'm not fully sure how they interact), so apologies if this issue should have been created on https://github.com/python/mypy instead (feel free to transfer it there if that's the case).
Metadata
Metadata
Assignees
Labels
No labels