basedpyright
can’t resolve a simple import numpy.typing
. What should I add to my configuration to get it to work?
For instance, if I have a file a.py
with a single line:
import numpy.typing as npt
I get this error when running basedpyright
:
> poetry run basedpyright a.py
/home/come/programming/python/basedpyright/a.py
/home/come/programming/python/basedpyright/a.py:1:8 - error: Import "numpy.typing" could not be resolved (reportMissingImports)
2 errors, 0 warnings, 0 notes
While mypy
runs successfully on the same file:
> poetry run mypy a.py
Success: no issues found in 1 source file
If I create my own virtual environment and run mypy
and basedpyright
directly, without poetry
, I get the same result.
I checked that I do have a typing
subdirectory in numpy:
> ls ~/venv/lib/python3.12/site-packages/numpy/typing/
__init__.py mypy_plugin.py __pycache__ tests
basedpyright
seems to work as expected for everything else. It’s only with numpy.typing
that I have a problem.
This is the pyproject.toml
that I am using:
[tool.poetry]
name = "demo"
version = "0.0.1"
description = "This is the python version of the demo package"
authors = ["Come Raczy <[email protected]>"]
[tool.poetry.dependencies]
numpy = ">=2.1.0"
python = ">=3.12,<4.0"
[tool.poetry.group.dev.dependencies]
mypy = ">=1.11.1"
data-science-types = "^0.2.23"
typing-extensions = "^4.12.2"
[tool.mypy]
plugins = "numpy.typing.mypy_plugin"
files = ["."]
[tool.pyright]
typeCheckingMode = "basic"