Skip to content

Please include a "how to fix it" example in the error message #9236

Closed
@bbkane

Description

@bbkane

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?

Feature request. A slightly more clear error message, which might be appreciated by folks newer to Python who aren't as familiar with the mini formatting language. If wanted, I'll contribute a pull request to fix this.

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
$ cat tmp.py
print("{}".format(b'abc'))
  • What is the actual behavior/output?
$ mypy tmp.py
tmp.py:1: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior
Found 1 error in 1 file (checked 1 source file)
  • What is the behavior/output you expect?

I'd love an example of what exactly to change. Something like:

$ mypy tmp.py
tmp.py:1: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior. Example: '{!r}'.format(b'abc'
Found 1 error in 1 file (checked 1 source file)
  • What are the versions of mypy and Python you are using?
$ python3 --version
Python 3.7.6
$ mypy --version
mypy 0.770

Do you see the same issue after installing mypy from Git master?

The error source code is still the same in Git master

  • What are the mypy flags you are using? (For example --strict-optional)

No flags

  • If mypy crashed with a traceback, please paste
    the full traceback below.

(You can freely edit this text, please remove all the lines
you believe are unnecessary.)

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