Skip to main content

unnotebook

CI PyPI version License: MIT

⚠️ Project status: early proof of concept (v0.1.0). The recognisers cover a narrow set of notebook shapes, and anything outside them is refused rather than guessed at.

Deterministic static analysis and refactoring for data-science code. unnotebook finds bugs in notebooks and scripts, fixes the ones it can prove, and rewrites a training notebook as a tested, hexagonal Python project.

  • No LLM, no execution. Everything is derived from the syntax tree (via the ruff parser crates). Your code is never run.
  • Proven fixes only. A finding is auto-fixed only when the fix is known to be correct; everything else is reported.
  • Refuses instead of guessing. If a stage of the pipeline is not recognised, rewrite stops and lists exactly what is missing.
  • A single native binary. Written in Rust; Python is only the language it analyses.

Installation

uv tool install unnotebook
# or
pip install unnotebook

The wheel carries only the native executable, so it works with any Python from 3.11. Static Linux executables (x86_64 and aarch64, musl) with build-provenance attestations are attached to each GitHub release:

gh attestation verify unnotebook-x86_64-unknown-linux-musl.tar.gz --repo w-martin/unnotebook

Commands

check

Reports data-science smells in .py files and .ipynb notebooks, with notebook cell coordinates.

unnotebook check analysis.ipynb
# analysis.ipynb:cell 3:2:1: API001 `.fillna(inplace=True)` on `df['Age']` updates a copy, so the original is never changed (a no-op under pandas >= 3 copy-on-write)
# analysis.ipynb:cell 3:3:1: API001 `.replace(inplace=True)` on `df['Sex']` updates a copy, so the original is never changed (a no-op under pandas >= 3 copy-on-write)
# Found 2 findings.
Code Finding
API001 Chained inplace=True call that silently updates a copy (auto-fixable)
LEAK001 Test data imputed or standardised with its own statistics, not train's
LEAK002 Encoder or dummies fitted separately on train and test
EVAL001 Model evaluated on its own training data
CFG001 Hard-coded absolute data path
REPRO001 No random seed set

fix

Rewrites files to remove the findings that have a proven fix, in place or into --output-dir.

unnotebook fix analysis.ipynb
# Fixed 2, 0 remaining.

rewrite

Turns a notebook, a script or a repository into a modular project:

unnotebook rewrite --output-dir titanic_pipeline titanic.ipynb

The generated project has:

  • hexagonal layers (domain, application, infrastructure) with dependencies pointing inward, and thin train, evaluate, predict and serve entrypoints exposed as console scripts;
  • a lazy composition root (container.py), so heavy optional libraries (Keras, MLflow, OpenTelemetry) are imported only when used;
  • preprocessing refitted on the training data only, with the leaks it corrected recorded in plan.toml;
  • typedframes schemas for the raw inputs, configuration in TOML, structured logging, a run manifest and a FastAPI inference service;
  • a stage-wise golden-master test that keeps the notebook's own preprocessing verbatim and checks the new pipeline against it on synthetic data.

Supported today: Keras Sequential models with Dense layers and scikit-learn classifiers built from literal arguments, with median/mode imputation, get_dummies one-hot encoding, row-wise feature engineering, and column selection. Given a repository, the one script that matches becomes the pipeline and the remaining scripts are carried over verbatim.

Exit codes

Code Meaning
0 Clean, or everything was fixed or rewritten
1 Findings remain, or rewrite could not place some statements
2 Error: unreadable input, syntax error, or rewrite refused the input

Building from source

Requires a Rust toolchain and uv.

git clone https://github.com/w-martin/unnotebook
cd unnotebook
uv sync
uv run unnotebook --help

The development gate (format, lint, tests) is uv run inv all.

License

MIT

Metadata

Release files for unnotebook 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unnotebook 0.1.0
File Size Uploaded Provenance Actions
unnotebook-0.1.0.tar.gz 82.7 kB With provenance Details for unnotebook-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for unnotebook 0.1.0
File Actions
unnotebook-0.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for unnotebook-0.1.0-py3-none-win_amd64.whl
unnotebook-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for unnotebook-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
unnotebook-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for unnotebook-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
unnotebook-0.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for unnotebook-0.1.0-py3-none-macosx_11_0_arm64.whl

Total release size: 5.1 MB

Release files / unnotebook-0.1.0.tar.gz

Download URL unnotebook-0.1.0.tar.gz
Size 82.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d230fe5e4651aa4406df7e9a577a633e948f80a02dcc958a9a803cd40ee2d07
BLAKE2b-256 checksum
How to use checksums
7da3eed71f216fef4f734745a036996b20b0fd044c618b837dfc295cead36de1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / unnotebook-0.1.0-py3-none-win_amd64.whl

Download URL unnotebook-0.1.0-py3-none-win_amd64.whl
Size 1.2 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
3a295b9254fd5ec01b9de7a2ff81342a7ff93626fd9eca0926db1a63dcd78171
BLAKE2b-256 checksum
How to use checksums
ddb943c1f6b9511f2eaa6251e3e170bfe5996ed36a34dcb9ee6fde3b89b7be19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / unnotebook-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL unnotebook-0.1.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0b86f54a69f4a4f2bca26b2e164d5cc6a1b7a7ffa73f6032bc3ee1cf610b72d3
BLAKE2b-256 checksum
How to use checksums
511545381822b9b5aa4db03b4275fd1c7fe1ed4c198dcd96e819583e545a8c37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / unnotebook-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL unnotebook-0.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
ac60986dca187927bc186c31cafb26079cc95e3fe40d64a78357916af6a4439a
BLAKE2b-256 checksum
How to use checksums
9746cc3b7d1bbf49f74acc55b8f666c7d28cb408bed8de45f253e15e8519d59b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / unnotebook-0.1.0-py3-none-macosx_11_0_arm64.whl

Download URL unnotebook-0.1.0-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
074d86a78f41a0b1e8068fd7904b2a7447be8aa5c3d87e3f6b5f52b21d90a327
BLAKE2b-256 checksum
How to use checksums
d3d579a36c772aed24c29185641ec74e8fbecb1920e0e7b9549b584d5b9ee8f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for unnotebook 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for unnotebook-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

5 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page