refactor(pieces): the shared surface loses its private marker - #442
Merged
Conversation
Inside an already-private module the leading underscore marks
module-PRIVATE, and the two established shared modules keep that
distinction without exception -- measured across the pipeline:
_vocab 12 bare names imported elsewhere, 0 underscored ones
_state 5 bare names imported elsewhere, 0 underscored ones
_pieces 0 bare names imported elsewhere, 8 underscored ones
_pieces inverted it. The sharpest illustration was inside the file:
Peel was bare and used only within the module, while _peel_walk was
underscored and imported by both stages -- the two most closely related
names each wearing the wrong marker. The cost is not aesthetic. In
_vocab a reader answers "may I call this from another stage?" from the
name; in _pieces that question needed a grep, and _PERIOD_ABBREV (truly
internal) looked exactly like _peel_trailing (the principal export).
Eight names lose the underscore, 84 references across five files.
_PERIOD_ABBREV keeps it, being internal. Peel keeps its CapWords type
name -- it has no underscore to drop, and its being internal today is
incidental: assign consumed it until #441 trimmed the import.
Settled in the same pass, since it is the same confusion pointed the
other way: _group imported _vocab's bare PH and D "as _PH/_D", adding
back at the import site the marker the source module had deliberately
dropped. They are imported under their own names now.
decisions.md is deliberately untouched -- its entries are dated
snapshots naming the symbols as they stood, which the #441 docs review
confirmed needs no amendment. mechanisms.md's Lives in is a live map
and moves.
VERIFIED AS A PURE RENAME, mechanically: applying the same substitution
to origin/master's copy of each of the five files yields a result
BYTE-IDENTICAL to this branch, so the diff contains the rename and
nothing else. Suite 5670, mypy and ruff clean, differential 0
unexplained.
A guard in the rename script caught one thing worth recording: two test
comments already wrote `is_leading_title()` without the underscore,
informally naming the very function being renamed. The first draft of
the guard flagged any textual occurrence of a new name and refused to
run; checking for BOUND names instead let it through, and the rename
makes those two comments literally correct.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #442 +/- ##
==========================================
- Coverage 98.59% 98.59% -0.01%
==========================================
Files 45 45
Lines 3068 3067 -1
==========================================
- Hits 3025 3024 -1
Misses 43 43 ☔ 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.
Follow-up to #441, which deliberately deferred this so its own diff could stay a verifiable byte-identical move.
Eight names in
_pieces.pylose their leading underscore. No behavior change — proved mechanically below.Why
Inside an already-private module the leading underscore marks module-private. The two established shared modules keep that distinction without exception:
_vocab_state_pieces_vocabalso keeps ten genuinely-internal helpers underscored —_dotted,_is_suffix_strict_n,_classify,_ROMAN— and none is imported anywhere. The signal is clean: bare means someone else calls this, underscore means don't._piecesinverted it, and the sharpest illustration was inside the file itself:Peelwas bare and used only within the module, while_peel_walkwas underscored and imported by both stages — the two most closely related names each wearing the wrong marker.The cost isn't aesthetic. In
_vocab, a reader deciding "may I call this from another stage?" answers it from the name. In_piecesthat needed a grep, and_PERIOD_ABBREV(truly internal) looked exactly like_peel_trailing(the principal export). The module also advertises itself as_vocab's sibling — mirrors its docstring title, quotes its contract — so the one place it departed read as oversight rather than decision.What changed
Renamed (8):
is_title_piece,is_leading_title,leading_titles,is_suffix_piece,segment_holds_no_name,peel_walk,trailing_start,peel_trailing— 84 references across five files.Kept:
_PERIOD_ABBREV, which is internal. AndPeel, which is a CapWords type name with no underscore to drop — its being internal today is incidental, since assign consumed it until #441 trimmed the import.Settled in the same pass, being the same confusion pointed the other way:
_groupimported_vocab's barePHandDas_PH/_D, adding back at the import site the marker the source module had deliberately dropped. They're imported under their own names now._pieces.pynow states the convention rather than merely following it, so the next shared module has something to copy.Verification
Proved a pure rename, mechanically. Applying the same substitution to
origin/master's copy of each of the five files yields a result byte-identical to this branch — so the diff contains the rename and nothing else:uv run pytestuv run mypyuv run ruff checkDocs
docs/design/decisions.mdis deliberately untouched: its entries are dated snapshots naming symbols as they stood on those dates, which the #441 docs review confirmed needs no amendment.mechanisms.md'sLives inis a live map and moves with the code.One thing worth recording
The rename script's guard refused to run at first: two test comments already wrote
is_leading_title()without the underscore, informally naming the very function being renamed. The first draft flagged any textual occurrence of a new name; checking for bound names instead (def/class/import/assignment) let it through — and the rename makes those two comments literally correct.🤖 Generated with Claude Code