添加自定义pylint检查器以进行预提交

时间:2019-06-07 23:55:10

标签: python-3.x pylint pre-commit-hook pre-commit

在我的本地仓库中,我有一个.pre-commit-config.yaml,其中包含以下内容:

exclude: '^$'
fail_fast: false
repos:
-   repo: git@github.com:me/pre-commit-hooks
    rev: 1.0.1
-   repo: https://github.com/pre-commit/mirrors-pylint
    rev: v1.9.1
    hooks:
    -   id: pylint
        language_version: python3.7

在我的git repo pre-commit-hooks中,我有pre-commit-config.yaml

-   id: flake8
    name: flake8
    description: "Runs flake8."
    entry: flake8
    language: python
    language_version: python3.7
    types: [file, python]
    verbose: true

-   id: pylint
    name: pylint
    description: "Runs pylint."
    entry: pylint --load-plugins=scripts/google_docstring_pylint
    language: python
    language_version: python3.7
    types: [file, python]
    verbose: true

-  id: isort
   name: isort
   description: "Runs isort to sort all imports."
   entry: isort_autolint
   language: python
   language_version: python3.7
   types: [file, python]
   verbose: true

在该存储库中,我还有文件scripts/google_docstring_pylint.py。这是一个自定义检查器,用于验证python文件是否具有Google文档字符串。当我运行

时,它运行良好
python3 -m pylint --load-plugins=scripts/google_docstring_pylint ../module/test.py

但是,当我运行pre-commit时,它不起作用。如何在预提交中运行自定义的pylint检查器?

0 个答案:

没有答案