Bug Report
This particular check seems to be incompatible with formatted string literals.
To Reproduce
$ mypy -c 'x = b""; f"{x}"'
<string>:1: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
Found 1 error in 1 file (checked 1 source file)
$ mypy -c 'x = b""; f"{x:r}"'
<string>:1: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.910
Expected Behavior
Should work in the same way as with str.format():
$ mypy -c 'x = b""; "{x}".format(x=x)'
<string>:1: error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior
Found 1 error in 1 file (checked 1 source file)
$ mypy -c 'x = b""; "{x:r}".format(x=x)'
Success: no issues found in 1 source file
Actual Behavior
See To Reproduce
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags: (see above)
- Mypy configuration options from
mypy.ini (and other config files): none
- Python version used: 3.9.6
- Operating system and version: Fedora 34 x86_64