Closed
Description
Discovered as part of python/typeshed#7679
Given the following:
from typing import Any, Callable, overload
@overload
def sublike(pattern: str, repl: Callable[[str], str]) -> str: ...
@overload
def sublike(pattern: bytes, repl: Callable[[bytes], str]) -> bytes: ...
def sublike(*args, **kwargs) -> Any: ...
def minv1() -> str:
return sublike("asdf", lambda m: f"{m}")
mypy produces:
test.py:10: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior
Found 1 error in 1 file (checked 1 source file)
If you change to return sublike("asdf", reveal_type(lambda m: f"{m}"))
, you get:
asdf.py:10: note: Revealed type is "def (m: Any) -> builtins.str"
asdf.py:10: note: Revealed type is "def (builtins.str) -> builtins.str"
asdf.py:10: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior
Found 1 error in 1 file (checked 1 source file)
So possibly related to the multipass logic for lambdas.