You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run Black and Flake8 in a repository where devs and the CI system will already have these packages installed in a virtual environment. As such, I don't want pre-commit to worry about cloning/installing these repos.
I think the right way to do this is to configure a repo: local block, which has mostly worked for me so far. Here is what I have in .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: black
name: black
entry: python -m black
language: system
types: [python]
- id: flake8
name: flake8
entry: python -m flake8
language: system
types: [python]
The problem I'm having is that neither of these tools are reading the config files that I have stored in the repository for them, i.e. pyproject.toml for Black and setup.cfg for Flake8. I've even gone so far as to specify the configuration settings as arguments to the hook, e.g. args: [--exclude=<exclude-regex>], but that still doesn't register the behavior I'd expect. The arguments appear to be passed to the script, but the formatting and linting doesn't match the configuration it should be getting.
My assumption is that each of these commands essentially maps to a shell invocation of the entry. For instance, the black hook should come out to python -m black <args> <staged-files>, launched from the same directory as the config files .pre-commit-config.yaml and pyproject.toml.
Am I mistaking how this should work, or is there something iffy going on here?
pre-commit --version
pre-commit 1.18.3
Thanks in advance!
The text was updated successfully, but these errors were encountered:
My assumption is that each of these commands essentially maps to a shell invocation of the entry. For instance, the black hook should come out to python -m black , launched from the same directory as the config files .pre-commit-config.yaml and pyproject.toml.
your assumption is correct and documented -- have you tried python -m black file1.py file2.py ...? you should see the same exact behaviour
Perfect. My confusion was with files excluded by black and flake8 by not excluded by pre-commit. When I moved these exclusions into .pre-commit-config.yaml everything worked as expected.
I'm trying to run Black and Flake8 in a repository where devs and the CI system will already have these packages installed in a virtual environment. As such, I don't want
pre-commit
to worry about cloning/installing these repos.I think the right way to do this is to configure a
repo: local
block, which has mostly worked for me so far. Here is what I have in.pre-commit-config.yaml
:The problem I'm having is that neither of these tools are reading the config files that I have stored in the repository for them, i.e.
pyproject.toml
for Black andsetup.cfg
for Flake8. I've even gone so far as to specify the configuration settings as arguments to the hook, e.g.args: [--exclude=<exclude-regex>]
, but that still doesn't register the behavior I'd expect. The arguments appear to be passed to the script, but the formatting and linting doesn't match the configuration it should be getting.My assumption is that each of these commands essentially maps to a shell invocation of the
entry
. For instance, theblack
hook should come out topython -m black <args> <staged-files>
, launched from the same directory as the config files.pre-commit-config.yaml
andpyproject.toml
.Am I mistaking how this should work, or is there something iffy going on here?
Thanks in advance!
The text was updated successfully, but these errors were encountered: