Incorrect suggestion for importing collections from typing
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
The following code:
a: Iterable
produces the following output:
test.py:1:4: error: Name "Iterable" is not defined [name-defined]
a: Iterable
^
test.py:1:4: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Iterable")
It should suggest importing from collections.abc, not from typing, starting with Python 3.9.
$ mypy --version
mypy 1.11.1 (compiled: yes)
$ python --version
Python 3.12.3
$ lsb_release -d
No LSB modules are available.
Description: Ubuntu 24.04 LTS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the diagnostic with the provided Python 3.12 example, then locate the mypy logic that generates import suggestions for undefined names. Update the relevant behavior so collections.abc.Iterable is suggested for Python 3.9 and newer, and verify the diagnostic wording across the supported version boundary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100