pythonmypypre-commitpre-commit.com

pre-commit with mirrors-mypy shows errors i already fixed


i cleaned cache with

pre-commit clean && pre-commit gc

but it still shows me errors i already fixed:

$ git commit -m "fake commit"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/user/.cache/pre-commit/patch1713289566-594939.
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

src/app/app_layer/interfaces/providers/db.py:7: error: Function is missing a type annotation for one or more arguments  [no-untyped-def]
src/app/app_layer/interfaces/providers/db.py:21: error: Function is missing a type annotation  [no-untyped-def]

in fact 21st string is empty. what did i do wrong?

here is my yaml config:

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.9.0
    hooks:
    - id: mypy
      pass_filenames: false
      language: system
      args: [
        src/,
        --python-version, "3.11",
        --cache-dir, /dev/null
      ]

Solution

  • from the output:

    [WARNING] Unstaged files detected.
    [INFO] Stashing unstaged files to /home/user/.cache/pre-commit/patch1713289566-594939.
    

    you have forgotten to run git add and it is only checking the contents that are about to be committed so your "fix" is not included


    disclaimer: I wrote pre-commit