Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pylint and pre-commit python 3.7

I am trying to set up pylint to work with pre-commit. I have looked into the docs, but still I am confused. I do not know how to setup .pre-commit-config.yaml properly.

Could you provide the most basic possible template?

-   repo: myrepo
    rev: ''  # Don't know that to type here
    hooks:
    -   id: pylint
like image 410
maslak Avatar asked Dec 02 '22 09:12

maslak


2 Answers

The most basic possible template would be this:

-   repo: https://github.com/pycqa/pylint
    rev: pylint-2.6.0
    hooks:
    -   id: pylint

You can also pass arguments to pylint:

-   repo: https://github.com/pycqa/pylint
    rev: pylint-2.6.0
    hooks:
    -   id: pylint
        args:
        - --max-line-length=80
        - --ignore-imports=yes
        - -d duplicate-code

Notes about compatibility:

  • Python >=3.7 requires pylint >= 2.0
  • Python 2 requires pylint < 2.0 (Python 2 support was dropped in Pylint 2)
like image 145
KevinG Avatar answered Dec 04 '22 00:12

KevinG


Here is a pre-commit config fragment that works for me using regular pylint instead of mirrors-pylint:

  - repo: https://github.com/pycqa/pylint
    rev: pylint-2.5.3
    hooks:
    -   id: pylint
        args:
        - --errors-only
like image 25
Todd Bradley Avatar answered Dec 04 '22 00:12

Todd Bradley