Incorrect diagnostic on missing submodule
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
When untyped module exists but submodule does not, mypy reports that submodule is installed.
To Reproduce
$ pip install fabric
import fabric
from fabric.not_exists import something
$ python3 test.py
Traceback (most recent call last):
File "/media/sf_d/WWPass/git/spm/test.py", line 2, in <module>
from fabric.not_exists import something
ModuleNotFoundError: No module named 'fabric.not_exists'
$ mypy test.py
test.py:1:1: error: Skipping analyzing "fabric": module is installed, but missing library stubs or py.typed marker [import-untyped]
import fabric
^
test.py:2:1: error: Skipping analyzing "fabric.not_exists": module is installed, but missing library stubs or py.typed marker [import-untyped]
from fabric.not_exists import something
^
test.py:2:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 2 errors in 1 file (checked 1 source file)
Expected Behavior
Error in line 2 should be saying that fabric.not_exists does not exist.
Actual Behavior
Error in line 2 says that fabric.not_exists is installed, which it not true and misleading.
Your Environment
$ mypy --version
mypy 1.11.2 (compiled: yes)
$ python3 --version
Python 3.12.3
$ pip list | grep fabric
fabric 3.2.2
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
Reproduce the report with the shown test.py, an installed untyped fabric package, and the import of fabric.not_exists. Start by tracing mypy's import resolution and missing-stub diagnostic for nested modules; done means the existing package still reports its current warning while the missing submodule gets a clear does-not-exist error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100