Check MyPy Import Errors
Check and prevent mypy errors due to missing stubs.
- class hooks.check_mypy_import_errors.CheckMypyImportErrors(argv: Optional[Sequence[str]] = None)
Hook to check whether mypy will raise import errors using the current project configuration, and fix the config file if necessary.
This is configured to only run when changes to your requirements.txt or pyproject.toml file are staged.
- run() int
Fix mypy parameters in
setup.cfg
orpyproject.toml
to prevent the CI pipeline giving import errors during linting jobs, as not all packages provide mypy support. To be run from within the top level repo directory.The function applies pylint to this repo, and greps the resultant output for any import error messages. The function will then append the bad package/module names to the relevant config file section to silence the error in future.
This is a known bug with mypy and in this case, silencing the errors is the only fix to prevent CI job failure.
- Raises
Exception – if mypy fails to run
- hooks.check_mypy_import_errors.main()
Hook entry point