Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pre-commit: run mypy in the main virtualenv
`pre-commit` will by default create an isolated virtualenv to run hooks such as `mypy`. This creates well-known issues because `mypy` won't have access to packages the code depends on. See python/mypy#13916 for recommendations by the `mypy` maintainer. By running `mypy` as a `system` hook as suggested, it will see the exact same packages as running `mypy` standalone (or through an IDE) will, which avoids discrepancies that appear only at commit time. The compromise is that running `mypy` through `pre-commit` will require a properly initialized virtualenv. However because we add a `files:` filter to the `mypy` hook, `pre-commit` will not run if no Python file has been changed; and if Python files have been changed it seems reasonable to expect a proper development environment has been set up. Also following the recommendation we set `pass_filenames: false` so that `pre-commit` does not pass only the changed files to `mypy`.
- Loading branch information