From 162d0926f939ce938279e73fd07ff6634ee35770 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 11 Jul 2023 04:30:07 -0700 Subject: mypy: add more ignored modules to `pyproject.toml` (#38769) `mypy` will check *all* imported packages, even optional dependencies outside your project, and this can cause issues if you are targeting python versions *older* than the one you're running in. `mypy` will report issues in the latest versions of dependencies as errors even if installing on some older python would have installed an older version of the dependency. We saw this problem before with `numpy` in #34732. We've started seeing it with IPython in #38704. This fixes the issue by exempting `IPython` and a number of other imports of Spack's from `mypy` checking. --- pyproject.toml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'pyproject.toml') diff --git a/pyproject.toml b/pyproject.toml index a89a206666..d33b27a99c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -141,12 +141,29 @@ ignore_missing_imports = true ignore_errors = true ignore_missing_imports = true - # pytest (which we depend on) optionally imports numpy, which requires Python 3.8 in - # recent versions. mypy still imports its .pyi file, which has positional-only - # arguments, which don't work in 3.7, which causes mypy to bail out early if you have - # numpy installed. + # Spack imports a number of external packages, and they *may* require Python 3.8 or + # higher in recent versions. This can cause mypy to fail because we check for 3.7 + # compatibility. We could restrict mypy to run for the oldest supported version (3.7), + # but that means most developers won't be able to run mypy, which means it'll fail + # more in CI. Instead, we exclude these imported packages from mypy checking. [[tool.mypy.overrides]] - module = 'numpy' + module = [ + 'IPython', + 'altgraph', + 'attr', + 'boto3', + 'botocore', + 'distro', + 'jinja2', + 'jsonschema', + 'macholib', + 'markupsafe', + 'numpy', + 'pyristent', + 'pytest', + 'ruamel.yaml', + 'six', + ] follow_imports = 'skip' follow_imports_for_stubs = true -- cgit v1.2.3-70-g09d2