Mypy false positive for converter
class attribute in logging.Formatter
class.
#19241
Labels
converter
class attribute in logging.Formatter
class.
#19241
Bug Report
Mypy false positive: Mypy thinks that setting the converter class attribute for a subclass of
logging.Formatter
to something liketime.gmtime
is wrong.To Reproduce
Expected Behavior
No error, since time.gmtime is annotated as
def gmtime(seconds: float | None = None, /) -> struct_time: ...
and the converter attribute is annotated asconverter: Callable[[float | None], struct_time]
.Actual Behavior
logger.py:45: error: Incompatible types in assignment (expression has type "Callable[[], struct_time]", base class "Formatter" defined the type as "Callable[[float | None], struct_time]") [assignment]
Your Environment
mypy.ini
(and other config files): NoneBy the way, this issue didn't exist in my Python3.12 environment with an older version of mypy installed, but I don't have access to that environment right now so I can't provide which mypy version it had.
The text was updated successfully, but these errors were encountered: