Search code examples
pylintpre-commit-hookpylintrc

Error while running pylint pre commit hook in django project


Pre-commit integration with pylint

Am using pre commit with this formula:

evaluation=max(0, 0 if fatal else  10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10))

while running pre-commit run --all-files am getting the error saying :

An exception occurred while rating: name 'fatal' is not defined

I also have pre-commit-config.yaml and .pylintrc files were also configured properly.

Here am attaching my yaml code:

repos:
  - repo: https://github.com/pycqa/pylint
    rev: v2.12.2
    hooks:
      - id: pylint
        args:
          - --fail-under=9
          - --rcfile=./.pylintrc
          - --disable=E0401 # for disabling import errors
        exclude: '/migrations/'

I tried searching in browser but can't find the solution


Solution

  • I think your yaml file version is not up to date. run this command to update version.

    pre-commit autoupdate

    This may solve your problem.