I have the following .pre-commit-config.yaml
file. At the first line, I have this top level exclude
path to exclude all checks in that folder, but for some reason, the mypy
hook still outputs errors from files in that folder. Could someone help me understand what's going on? Thanks.
exclude: "src/project/proto/"
default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
args: [--py3-plus]
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.3.0
hooks:
- id: add-trailing-comma
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
args: [--strict]
additional_dependencies:
[types-protobuf>=4.21.0.0, types-termcolor>=1.1.6, pytest>=7.2.0]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
I also have this mypy.ini
. Just in case, I missed anything here.
[mypy]
python_version = 3.8
mypy_path = ./src:./tests
[mypy-lark.*]
ignore_missing_imports = True
it is working, but not in the way you expect
mypy performs dynamic analysis and will follow imports. pre-commit is not passing those filenames onto mypy but they are being checked due to follow-imports
you will need to also use mypy
's settings to ignore errors there
disclaimer: I created pre-commit