Closed
Description
Bug Report
On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"
gets produced during bidirectional inference in a failed overload match.
To Reproduce
from typing import overload, Callable
@overload
def sub(pattern: str, repl: Callable[[str], str]) -> str: ...
@overload
def sub(pattern: bytes, repl: Callable[[bytes], bytes]) -> bytes: ...
def sub(pattern: object, repl: object) -> object:
raise NotImplementedError
def better_snakecase(text: str) -> str:
text = sub(r"([A-Z])([A-Z]+)([A-Z](?:[^A-Z]|$))", lambda match: f"{match}")
return text
Expected Behavior
No errors
Actual Behavior
test_cases/stdlib/typing/pattern.py:11: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior
Your Environment
- Mypy version used: master, 0.942
- Mypy command-line flags: none
Found in python/typeshed#7679, the repro case minified from some code in homeassistant.