Skip to content

logging.LoggerAdapter missing extra instance variable #2350

@wkschwartz

Description

@wkschwartz

The following test case fails. Place the following code in mypy-test.py:

import logging
from typing import Any, MutableMapping, Tuple
class Adapter(logging.LoggerAdapter):
	def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]:
		data = self.extra['data']
		return ('%s' % data), kwargs

Then I get

$ mypy mypy-test.py 
mypy-test.py:5: error: "Adapter" has no attribute "extra"

This location should have extra: Mapping[str, Any] put right below it.

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