Skip to content

ComPWA/nbhooks

Repository files navigation

ComPWA notebook hooks

BSD 3-Clause license Spelling checked CI Test coverage pre-commit.ci status code style: prettier uv Ruff ty

This repository provides pre-commit hooks for formatting and standardizing Jupyter notebooks in repositories of the ComPWA organization (see our Help developing page).

Usage

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-whitespace

then run

pre-commit autoupdate --repo=https://github.com/ComPWA/nbhooks

This 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.