You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invalid error: On Python 3 '{}'.format(b'abc') produces "b'abc'", not 'abc'; use '{!r}'.format(b'abc') if this is desired behavior when using formatted string literals #10979
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