Closed avivajpeyi closed 4 years ago
The python file flake8_black.py
is not intended to be executed directly, only via flake8
.
Looking at the pre-commit.com page you linked to, this example looks most relevant:
https://github.com/asottile/cheetah_lint/blob/master/.pre-commit-config.yaml https://github.com/asottile/cheetah_lint/blob/master/.pre-commit-hooks.yaml
However, you are probably better off just calling black --check
directly without the need for flake8 or the flake8-black plugin.
i.e. Something based on this but adding the --check
argument (rather than the default of just editing the files)?
https://github.com/psf/black/blob/master/.pre-commit-hooks.yaml
Ok, so you are suggesting to use black and flake8 instead of flake8-black:
- id: black
name: black
description: runs black
entry: black --check
language: python
- id: flake
name: flake
description: runs flake8
entry: flake8 --check
language: python
Calling black --check
is one solution, it does not need flake8 at all.
You could still use flake8-black
just like any other flake8 plugin - I don't know of a good example to point you at, but the key is probably just adding the plugin as a dependency to ensure it is installed too.
to use flake8 with plugins you'd use (for example):
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
additional_dependencies: [flake8-black==...]
Thank you all for your input. Closing pull request having added a line to the README saying that with pre-commit you do not need flake8-black. I'm going to try this myself sooner or later...
I would like to use flake8-black as a precommit plugin (https://pre-commit.com/hooks.html). I have tried to set it up, but think I am making a mistake:
Would the flak8-black team have any suggestions?