-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Our v0.14.0 reusable-mypy action runs the following mypy command:
mypy --install-types --ignore-missing-imports --non-interactive --pretty .
I observe some unexpected behavior with --ignore-missing-imports and --install-types. Using burst2safe as an example, if I checkout the latest develop commit, build the mamba environment and run the above command, it installs types-python-dateutil-2.9.0.20241206 and flags no issues.
However, if I remove .mypy_cache/ and re-build the environment, then run the above command without --ignore-missing-imports, it installs lxml-stubs-0.5.1 types-Pygments-2.19.0.20250107 types-colorama-0.4.15.20240311 types-docutils-0.21.0.20241128 types-python-dateutil-2.9.0.20241206 types-setuptools-75.8.0.20250110 and then flags 200 errors in 28 files.
Some of these errors do not seem directly related to missing imports, e.g. src/burst2safe/safe.py:338: error: Cannot determine type of "size_bytes" for L338, or even if it is, that's not an error that we would want to ignore. I thought that particular error might be related to importing Kml via from burst2safe.manifest import Kml, Manifest, Preview at L14 because perhaps mypy does not recognize the burst2safe package, but installing the package via pip install -e . or using a relative import for that line both did not change the number of errors reported, so I'm not sure what's going on there.
Also, if I run the mypy command with only --ignore-missing-imports, then the only error it flags is:
src/burst2safe/burst_id.py:11: error: Library stubs not installed for "dateutil" [import-untyped]
which I suppose makes some sense since that's the library for which stubs are installed when I run the full mypy command, though I'm not sure why --ignore-missing-imports doesn't suppress that particular import.
So, my main concerns are:
- Why does using
--ignore-missing-importsprevent installation of stubs for all libraries (other thandateutil)? I think we want to install as many stubs as possible. - Some of the ignored errors are not errors that we should be ignoring.
I think that the ideal resolution to this issue would be to:
- Remove
--ignore-missing-importsfrom our reusable action, and avoid enabling it inpyproject.tomlfor new projects (will need to be added topyproject.tomlfor existing projects where removing it would cause many errors). - Gradually remove it from
pyproject.tomlfor existing projects as time allows. - Going forward, use more granular methods of ignoring specific imports as needed. See Missing imports.