diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2022-12-31 17:05:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-01 01:05:17 +0000 |
commit | ca265ea0c268d1be05c85e66b25916e0d8c85932 (patch) | |
tree | a5413e20e544e013e5848da3be2d288c06a27f49 /.readthedocs.yml | |
parent | 7a925794806846919ba71b6d30e308297731ced0 (diff) | |
download | spack-ca265ea0c268d1be05c85e66b25916e0d8c85932.tar.gz spack-ca265ea0c268d1be05c85e66b25916e0d8c85932.tar.bz2 spack-ca265ea0c268d1be05c85e66b25916e0d8c85932.tar.xz spack-ca265ea0c268d1be05c85e66b25916e0d8c85932.zip |
style: fix spurious `mypy` errors from `numpy` (#34732)
Spack imports `pytest`, which *can* import `numpy`. Recent versions of `numpy` require
Python 3.8 or higher, and they use 3.8 type annotations in their type stubs (`.pyi`
files). At the same time, we tell `mypy` to target Python 3.7, as we still support older
versions of Python.
What all this means is that if you run `mypy` on `spack`, `mypy` will follow all the
static import statements, and it ends up giving you this error when it finds numpy stuff
that is newer than the target Python version:
```
==> Running mypy checks
src/spack/var/spack/environments/default/.spack-env/._view/4g7jd4ibkg4gopv4rosq3kn2vsxrxm2f/lib/python3.11/site-packages/numpy/__init__.pyi:638: error: Positional-only parameters are only supported in Python 3.8 and greater [syntax]
Found 1 error in 1 file (errors prevented further checking)
mypy found errors
```
We can fix this by telling `mypy` to skip all imports of `numpy` in `pyproject.toml`:
```toml
[[tool.mypy.overrides]]
module = 'numpy'
follow_imports = 'skip'
follow_imports_for_stubs = true
```
- [x] don't follow imports from `numpy` in `mypy`
- [x] get rid of old rule not to follow `jinja2` imports, as we now require Python 3
Diffstat (limited to '.readthedocs.yml')
0 files changed, 0 insertions, 0 deletions