Skip to content

Document using pre-commit and how --force-exclude can help  #3015

@ichard26

Description

@ichard26

Perhaps we should document this issue in the FAQ? Using pre-commit with Black is pretty common (and it's not always instantly clear it passes all of the files to the hook directly bypassing any file discovery the hook may implement). I'd suggest pre-commit's exclude configurations first, and then black's force-exclude.

Originally posted by @ichard26 in #3013 (comment)


For context, we added the --force-exclude option as pre-commit always passes all filepaths to the hook directly via the command line. It doesn't care whether the filepath came from the CLI or was recursively discovered, unlike --exclude or --include

We could also document it here: https://black.readthedocs.io/en/stable/integrations/source_version_control.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: file collectionRelated to file collection (e.g. gitignore & cache) or file discovery and all of its configuration.C: integrationsEditor plugins and other integrationsT: documentationImprovements to the docs (e.g. new topic, correction, etc)good first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions