Repository navigation
chore(notebooks): a pre-commit hook that tidies the notebooks in a commit - #861
Merged
Merged
Conversation
…mmit Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
petercorke
enabled auto-merge (squash)
October 19, 2026 21:22
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 4 medium 1 minor 8 high |
🟢 Metrics 19 complexity · 0 duplication
Metric Results Complexity 19 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #861 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 146 146
Lines 16846 16846
=====================================
Misses 16846 16846 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Editing a notebook and committing it should be all there is to do. This adds a git pre-commit hook that does the notebook tidying (#859) for the notebooks in each commit, so that nobody has to remember to run
clear_outputs.py. No change to the toolbox or to any notebook.What changes
docs/notebooks/pre_commit.py: for each staged notebook it adds cell ids and regenerates the bootstrap cell (sync_bootstrap.py), then clears outputs, resets the editor metadata and writes the file as Jupyter does (clear_outputs.py), and stages the result. It refuses the commit, with a message, if a notebook still has merge conflict markers (before, the scripts failed with a JSON traceback).python docs/notebooks/pre_commit.py --installwrites a three-line stub into the git directory'shooks/(shared by all worktrees), which runs the script in the repository being committed to. It does not overwrite a hook that is not its own. The code lives in the repository, so it survives a fresh clone.docs/notebooks/README.md: the routine for editing a notebook is now "edit and commit", with the manual commands for anyone who does not install the hook. CI still runs both checks.Tested with 3 new unit tests and by hand in a scratch git repository with the real hook installed: a notebook with outputs, an execution count and VS Code metadata was committed with none of them, with ids and canonical metadata; a commit of a notebook with conflict markers was refused. Written with AI assistance (Claude Code).
🤖 Generated with Claude Code