Skip to content

notebook-uniformity hook: drive it from the convention points - #1688

Open
classiqdor wants to merge 1 commit into
mainfrom
notebook_uniformity_hook_uses_points
Open

notebook-uniformity hook: drive it from the convention points#1688
classiqdor wants to merge 1 commit into
mainfrom
notebook_uniformity_hook_uses_points

Conversation

@classiqdor

Copy link
Copy Markdown
Contributor

Follow-up to the conventions kit (#1673) and the pre-commit-tools refactor (#1686).

What

The notebook-uniformity pre-commit hook used to re-implement the same regexes that already live in .internal/conventions/points/. It now imports the points and applies their fix() instead — one source of truth per convention.

  • The hook loads every point marked enforced, applies its fix(), then reports any enforced point that still fails (e.g. opens_h1, which has no auto-fix and can only be reported).
  • Points are reached through a new points symlink../conventions/points (mode 120000), so the import is a plain from points._model import … with no sys.path juggling — same spirit as metadata_validate importing its siblings.
  • Adding or changing an enforced rule is now a one-file edit under points/; the hook needs no changes.

Unchanged

  • The enforced set is identical: show, result_value, references, single_h1, opens_h1.
  • Behaviour: auto-fix on commit, fail so you re-git add, report the unfixable ones.
  • Hook shrinks from ~200 to ~80 lines.

Verification

  • Clean notebooks → no-op (ran on real notebooks with auto-fix on; zero false modifications).
  • Crafted violations (qprog.show(), singular ## Reference) → auto-fixed to show(qprog) / ## References, reported, exit 1; re-run → clean.
  • The validate symlinks hook passes on the new symlink.

Note

Depends on the points living on main (merged via #1673) — safe to merge now.

The hook re-implemented the same regexes that live in .internal/conventions/
points/. Now it imports the points (via a new 'points' symlink to
../conventions/points — no sys.path juggling) and applies the fix() of every
point marked 'enforced', then reports any enforced point that still fails
(e.g. opens_h1, which has no auto-fix).

One source of truth per convention: adding/changing an enforced rule is now a
one-file edit under points/. Hook drops from ~200 to ~80 lines; behaviour and
the enforced set (show, result_value, references, single_h1, opens_h1) unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant