pre-commit-ci / issues

public issues for https://pre-commit.ci
17 stars 3 forks source link

pyproject.toml config is ignored for black pre-commit #34

Closed neutrinoceros closed 3 years ago

neutrinoceros commented 3 years ago

Hi ! I just tried to setup pre-commit-ci on a project where I use the code formatter black. I report that pre-commit-ci seems run the corresponding hook in a way that ignores the associated configuration from pyproject.toml. Specifically, my config excludes whych/externs from black's scope, but as can be seen on this PR, it is applied there anyway: https://github.com/neutrinoceros/whych/pull/2

As running either black . or pre-commit run locally doesn't reproduce this behaviour, I assume this is a bug in pre-commit-ci

MarcoGorelli commented 3 years ago

exclude from pyproject.toml only works when running black on a directory, I think you want force-exclude, check the black docs

pre-commit run locally doesn't reproduce this behaviour,

are you sure? did you run pre-commit run --all-files?

neutrinoceros commented 3 years ago

are you sure? did you run pre-commit run --all-files?

Indeed adding the --all-files flag produces consistent changes with what happens on my pr.

exclude from pyproject.toml only works when running black on a directory, I think you want force-exclude, check the black docs

I wasn't aware of force-exclude, though it ought to be noted that changing exclude to force-exclude in my configuration doesn't affect pre-commit's behaviour (but then it's not a problem in pre-commit.ci). Thanks for your answer, I think this can be closed.