This repository provides pre-commit hooks for formatting and standardizing Jupyter notebooks in repositories of the ComPWA organization (see our Help developing page).
Add a .pre-commit-config.yaml file to your repository with the following content:
repos:
- repo: https://github.com/ComPWA/nbhooks
rev: ""
hooks:
- id: colab-toc-visible
- id: fix-nbformat-version
- id: remove-empty-tags
- id: set-nb-cells
- id: set-nb-display-name
- id: strip-nb-whitespacethen run
pre-commit autoupdate --repo=https://github.com/ComPWA/nbhooksThis example lists all available hooks (listed here as ids) ― you can remove some of them.
| Hook ID | Description |
|---|---|
colab-toc-visible |
Show the table-of-contents sidebar in Google Colab by default. |
fix-nbformat-version |
Set the nbformat minor version to 4 and remove cell IDs. |
remove-empty-tags |
Remove the tags metadata field from cells when it is empty. |
set-nb-cells |
Add or replace standard cells (install cell, config cell, autolink). |
set-nb-display-name |
Reset the notebook kernel display name to a standard value. |
strip-nb-whitespace |
Remove trailing whitespace from notebook cells. |