python / python/mypy

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

Open
#18,530 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-error-reporting
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported example with mypy 1.10.0 and compare the current diagnostic with the expected List wording. Locate the code or tests responsible for the type-argument error message, then add coverage showing that typing.List is reported as List and confirm the diagnostic matches the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.