Skip to content

str-bytes-safe displays position in line incorrectly #7740

Closed
@jolaf

Description

@jolaf

The following code:

s = '%s%s' % (b''.decode(), b'')

produces the following output:

$ python3 Test.py
$ mypy --show-column-numbers --pretty --show-error-codes Test.py 
Test.py:1:15: error: On Python 3 '%s' % b'abc' produces "b'abc'"; use %r if this is a desired behavior  [str-bytes-safe]
    s = '%s%s' % (b''.decode(), b'')
                  ^
Found 1 error in 1 file (checked 1 source file)
$ mypy --version
mypy 0.740
$ python3 --version
Python 3.6.8

Note that the indicated position of the error in the line is pointing to the first argument (b''.decode()) instead of the seconds one (b'') which is highly misleading.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions