pythongitflake8pre-commitpre-commit.com

How to block pre-commit using 100% of my CPU?


I have the pre-commit config file with pre-push hook type. Every time when I push to the repo, my CPU shows me 100% of using power.

enter image description here

Why it happens? How can I set a border for max power?

.pre-commit-config.yaml

repos:
-   repo: local
    hooks:
    -   id: flake8
        name: flake8
        description: linter
        entry: flake8 --select=C812,WPS120,F401,WPS510 --config=setup.cfg server/apps/
        language: python
        types: [python]

Solution

  • you've misconfigured flake8 and so you are triggering a fork bomb (pre-commit's multiprocessing + flake8's multiprocessing) and you're double-linting every file in your codebase

    I would recommend you utilize the official flake8 configuration rather than reimplementing your own (poorly):

    -   repo: https://github.com/pycqa/flake8
        rev: 4.0.1
        hooks:
        -   id: flake8
    

    disclaimer: I created pre-commit and I'm the current flake8 maintainer