Unintuitive behaviour when only subpackage provides py.typed
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
from numba import typed causes mypy to generate spurious attr-defined errors for everything else imported from numba.
To Reproduce
from numba import njit, typed # error: Module has no attribute "njit" [attr-defined]
Expected Behavior
scratch.py:1: error: Skipping analyzing "numba": module is installed, but missing library stubs or py.typed marker [import]
scratch.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Actual Behavior
scratch.py:1: error: Module "numba" has no attribute "njit" [attr-defined]
Your Environment
- Mypy version used: 1.5.1
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.8.8, 3.10.9, 3.11.5
$ .venv/bin/pip freeze
importlib-metadata==6.8.0
llvmlite==0.40.1
mypy==1.5.1
mypy-extensions==1.0.0
numba==0.57.1
numpy==1.24.4
tomli==2.0.1
typing_extensions==4.8.0
zipp==3.17.0
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 scratch.py import and the listed mypy, Python, and numba versions. Start by tracing how mypy handles installed packages when only a subpackage provides py.typed; done means the import no longer produces the spurious attr-defined error and a regression test covers this layout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100