使用镜像进行预提交-mypy 显示我已经修复的错误

问题描述 投票:0回答:1

我用

清理了缓存
pre-commit clean && pre-commit gc

但它仍然显示我已经修复的错误:

$ 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]

事实上第 21 个字符串是空的。我做错了什么?

这是我的 yaml 配置:

  - 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
      ]
python mypy pre-commit pre-commit.com
1个回答
0
投票

从输出:

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

您忘记运行

git add
,它只是检查即将提交的内容,因此不包括您的“修复”


免责声明:我写了预提交

© www.soinside.com 2019 - 2024. All rights reserved.