Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy should use List when complaining about issues with the List type, instead of list #18530

Open
hamirmahal opened this issue Jan 25, 2025 · 2 comments
Labels

Comments

@hamirmahal
Copy link
Contributor

Bug Report

mypy should use List when surfacing errors with the List type, not list.

It's confusing to engineers if mypy uses list when complaining about a type error because then engineers are searching the source code for occurrences of list, when the problem is actually with the usage of List.

To Reproduce

        self.orders: typing.List[typing.List[int, int]] = []

Expected Behavior

mypy should complain with

error: "List" expects 1 type argument, but 2 given  [type-arg]

Actual Behavior

mypy actually complains with

error: "list" expects 1 type argument, but 2 given  [type-arg]

Your Environment

  • Mypy version used: mypy==1.10.0
  • Mypy command-line flags: n/a
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: Python 3.10.12
@hamirmahal hamirmahal added the bug mypy got something wrong label Jan 25, 2025
@A5rocks
Copy link
Collaborator

A5rocks commented Jan 25, 2025

This is a feature request but I will note that:

  • you can get an underline via --pretty which should handle any confusion
  • doing this would be inconsistent with other error messages

@A5rocks A5rocks added feature topic-error-reporting How we report errors and removed bug mypy got something wrong labels Jan 25, 2025
@A5rocks
Copy link
Collaborator

A5rocks commented Jan 25, 2025

Actually, --pretty doesn't have as good of a start to end column as I would expect:

x.py:5: error: "list" expects 1 type argument, but 2 given  [type-arg]
    x: typing.List[typing.List[int, int]] = []
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 1 source file)

I reported this separately as #18531.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants