I can't exlude the directory from my pre-commit

1k Views Asked by At

My goal it's exlude migrations/ from my pre-commit.

I have my .pre-commit-config.yaml which begin with

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.3.0
    hooks:
    -   id: check-yaml
    -   id: debug-statements
    -   id: end-of-file-fixer
    -   id: trailing-whitespace
        exclude: ^(tests/fixtures/|migrations/)
-   repo: https://github.com/asottile/reorder_python_imports
    rev: v3.8.4
    hooks:
    -   id: reorder-python-imports
        args: [--application-directories, '.:src', --py36-plus]
-   repo: https://github.com/asottile/pyupgrade
    rev: v3.1.0
    hooks:
    -   id: pyupgrade
        args: [--py36-plus]
-   repo: https://github.com/psf/black
    rev: 22.10.0
    hooks:
    -   id: black
        args: [--line-length=119]
-   repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
    -   id: flake8
        args: [--max-line-length=119]
-   repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.982
    hooks:
    -   id: mypy
        exclude: ^(docs/|example-plugin/|migrations/)

But my pre-commit going to migrations and validate my rubbishcode)

I get:

mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

support/ticket/migrations/0001_initial.py:10: error: Need type annotation 
         for "dependencies" (hint: "dependencies: List[<type>] = ...")

Found 1 error in 1 file (checked 30 source files)

What i should to do?

1

There are 1 best solutions below

0
hauntsaninja On

Use pass_filenames: false in your pre-commit config and specify entry to the exact mypy command you want to run.