Search code examples
pythonpylintpre-commit

define score limit for pylint with pre-commit git hook


I am trying to set a accepted pylint score limit for my pre-commit git hook. I have tried two approaches:

A) adding it to the .pylintrc file

[pre-commit-hook]
command=custom_pylint
disable=E0401, C0301
limit=8.0

B) adding it as argument to .pre-commit-config.yaml

  - repo: https://github.com/pycqa/pylint
    rev: v2.12.2
    hooks:
      - id: pylint
        args:
          - --limit=7
          - --rcfile=./.pylintrc

Sadly for A, it just does not except it independent of the score. For B, I get the error, pylint: error: no such option: --limit.

Best regards


Solution

  • You should use --fail-under=7, not --limit see documentation.

    You can also read the output of pylint --help.