在 git bash 中使用 mypy 进行预提交未显示失败的位置

问题描述

长话短说,由于公司政策,我必须在我们的 bitbucket 服务器上制作此存储库的本地副本:https://github.com/pre-commit/mirrors-mypy

我有一个带有 .pre-commmit-config.yaml 文件的 python 项目,如下所示:

repos:
-   repo: http://host/scm/~user/local_pre-commit_mypy.git
    rev: 'hash'
    hooks:
        - id: mypy
          name: mypy
          types: [python]

当我跑步时:

pre-commit run

在我的 pycharm 终端中,我得到一个我想要的输出,如下所示:

[INFO] Initializing environment for http://host/scm/~user/local_pre-commit_mypy.git.
[INFO] Installing environment for http://host/scm/~user/local_pre-commit_mypy.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

OCR_test.py:14: error: Function is missing a return type annotation
OCR_test.py:14: note: Use "-> None" if function does not return a value
OCR_test.py:30: error: Function is missing a return type annotation
OCR_test.py:30: note: Use "-> None" if function does not return a value
OCR_test.py:50: error: Function is missing a type annotation
OCR_test.py:77: error: Function is missing a type annotation
OCR_test.py:96: error: Function is missing a return type annotation
OCR_test.py:96: note: Use "-> None" if function does not return a value
OCR_test.py:101: error: Function is missing a return type annotation
OCR_test.py:101: note: Use "-> None" if function does not return a value
OCR_test.py:130: error: Call to untyped function "upload_files_to_cloud" in typed context
Found 7 errors in 1 file (checked 1 source file)

这正是我所期望和想要的

但是当我跑步时:

 git commit -a -m"Changed pre commit stuff"

结果如下:

[INFO] Initializing environment for http://host/scm/~user/local_pre-commit_mypy.git.
[INFO] Installing environment for http://host/scm/~user/local_pre-commit_mypy.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

这主要给了我我想要的东西,但没有给我正确的输出,比如是什么文件和行导致它失败。

我希望 gitbash 的输出看起来像 pycharm 终端的输出 是我做错了什么,还是这正常?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)