简体   繁体   English

使用预提交时,mypy 检查通过但打印 mypy 语法错误

[英]when use pre-commit, mypy check passed but print mypy syntax error

I use pre-commit to run mypy type check, and when mypy check passed it print string error logs like this.我使用预提交来运行 mypy 类型检查,当 mypy 检查通过时,它会像这样打印字符串错误日志。

/username/.cache/pre-commit/repo61b8m7wl/py_env-python3.9/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/builtins.pyi:33: error: syntax error in type comment

this is very annoying because similar logs printed like 20 lines or 30 lines and it is not even related to code that I wrote.这很烦人,因为类似的日志打印了 20 行或 30 行,甚至与我编写的代码无关。 How can I disable this?我怎样才能禁用它?

this is my pre-commit config file.这是我的预提交配置文件。

repos:
  
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.720
    hooks:
     - id: mypy
       verbose: true
       entry: bash -c 'mypy "$@" || true' --

I use pre-commit to run mypy type check, and when mypy check passed it print string error logs like this.我使用pre-commit来运行mypy类型检查,当mypy检查通过时,它会打印出这样的字符串错误日志。

/username/.cache/pre-commit/repo61b8m7wl/py_env-python3.9/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/builtins.pyi:33: error: syntax error in type comment

this is very annoying because similar logs printed like 20 lines or 30 lines and it is not even related to code that I wrote.这很烦人,因为类似的日志打印成20行或30行,甚至与我编写的代码都不相关。 How can I disable this?如何禁用此功能?

this is my pre-commit config file.这是我的预提交配置文件。

repos:
  
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v0.720
    hooks:
     - id: mypy
       verbose: true
       entry: bash -c 'mypy "$@" || true' --

The accepted answer didn't work for me.接受的答案对我不起作用。 To fix the problem, I used a different rev :为了解决这个问题,我使用了不同的rev

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v0.910'
    hooks:
      - id: mypy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM