Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using types_or over files in pre-commit hook config #298

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion .pre-commit-hooks.yaml
Expand Up @@ -3,4 +3,11 @@
description: Run `black` on python code blocks in documentation files
entry: blacken-docs
language: python
files: '\.(rst|md|markdown|py|tex)$'
types_or: [rst, markdown, tex, python, pyi]
- id: blacken-docs-jupyter
name: blacken-docs-jupyter
description: Run `black` on python code blocks in documentation files (with Jupyter Notebook support)
entry: blacken-docs
language: python
types_or: [rst, markdown, tex, python, pyi, jupyter]
additional_dependencies: ["black[jupyter]"]
10 changes: 10 additions & 0 deletions README.rst
Expand Up @@ -48,6 +48,16 @@ Add the following to the ``repos`` section of your ``.pre-commit-config.yaml`` f
additional_dependencies:
- black==22.12.0

Or with Jupyter notebook support
(note the latest ``black[jupyter]`` is built-into this hook):

.. code-block:: yaml

- repo: https://github.com/adamchainz/blacken-docs
rev: "" # replace with latest tag on GitHub
hooks:
- id: blacken-docs-jupyter

Then, reformat your entire project:

.. code-block:: sh
Expand Down