Hi, I'm trying to setup `pre-commit` with pants bu...
# general
a
Hi, I'm trying to setup
pre-commit
with pants but it seems that it does not read some configuration files, currently running directly from pants everything works as expected but when running from pre-commit it fails on
bandit
and
mypy
both are customized using
pyproject.toml
in their corresponding sections bandit `args`: are
--quiet
and then when I run
pre-commit
the output is not quiet so I guess is not reading the configuration from the
pyproject.toml
any clue?
.pre-commit.config.yaml
Copy code
fail_fast: false
repos:
  - repo: local
    hooks:
      - id: pants-lint
        name: pants lint
        always_run: false
        description: runs pants --no-dynamic-ui lint on python files
        entry: pants --changed-since=HEAD --changed-dependents=transitive lint
        language: system
        verbose: true
        pass_filenames: false
        types: [file, python]
pants.toml
Copy code
[bandit]
args = "--quiet"
config = "./pyproject.toml"
install_from_resolve = "python-default"
f
I am not sure if this is a copy-paste issue, but the pre-commit config file should be named
.pre-commit-config.yaml
whereas your file is named
.pre-commit.config.yaml
. Please see https://pre-commit.com/#2-add-a-pre-commit-configuration. There's also another Slack thread you may find helpful.
I've created a PR https://github.com/AlexTereshenkov/cheeseshop-query/pull/34/files for you to try reproduce the issue. You can try to do:
Copy code
echo "\nprint('Done')" >> cheeseshop/cli/cli.py
git add . ; pre-commit
āœ“ bandit succeeded.
(no messages from Bandit)
Remove
skips = ["B101"]
and now there's an error and the detailed output is shown. So I can confirm that both
pyproject.toml
is read and the
args = "--quiet"
is respected by Pants as well (it's passing the args through). Try comment/uncomment
#args = "--quiet"
in
pants.toml
a
sorry for late response the
.pre-commit-config.yaml
was a typo here in the chat... but for some reason I get different outputs in pre-commit and in pants šŸ˜ž
f
no worries! If you check out the PR of mine locally and then write down what changes you make and what you run + the output, I could try to reproduce!