Skip to content

Correct stale docstrings, comments and stage headers - #1439

Merged
derek73 merged 2 commits into
masterfrom
docs/sweep-code-prose
Nov 16, 2026
Merged

derek73 merged 2 commits into
masterfrom
docs/sweep-code-prose

Conversation

@derek73

@derek73 derek73 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Section B of the 3.1 release sweep (root AGENTS.md, release checklist step 0): prose inside nameparser/ that no longer says what the tree does. Every finding was re-run on origin/master (f510237) before it was edited, and every replacement example was run too (script and output below).

No reading moves. The only executable text changed is two message strings. Stripping docstrings and comparing each changed module's AST with master gives identical trees for 17 of the 18 modules; _lexicon.py differs only in those two strings. git diff --stat origin/master -- tools/differential nameparser/config is empty, so snapshot.jsonl is byte-identical, and the frame guards pass.

Findings and what was done

Rendered docstrings and messages

Finding Done
Parser.suggest: initials_as_family "not turned on under a base … folding every middle into the family" Fixed. Only a family-first base stands down (tests/v2/test_suggest.py ~2400 pins the middle-fold case). docs/suggest.rst does not carry the wrong sentence: its "A base that reads names family first is suggested no change" is right.
locales/zh.py recipe Lexicon.default().add(surnames={...}) raises TypeError Fixed to Lexicon.default() | Lexicon(surnames={...}), and run: 玍明明 reads family 玍 with it, 玍明明 whole without it.
NameEvidence: "A name with a comma … casts none" Fixed: a comma followed only by post-nominals votes (Kim Minjun, PhD, the docs' own example).
_lexicon.py after_particle refusal cites rules/O7 Fixed to P10 (P10, a given name's second half after a particle). No test pinned the old text.
AmbiguityKind.CONJUNCTION_OR_INITIAL: "read as an initial and not reported" Fixed: "not reported as this kind"; JOSE E and jose e phd carry an order report (rules/O4, #1254).
Lexicon.words example lists md, mohd, moh Fixed: lists md, mohd and moh among others, rather than a list that goes stale.
_MaskValueError offers capitalization_exceptions=(('phd','PHD'),), which drops every shipped mask when pasted Fixed: offers the additive dataclasses.replace(lexicon, capitalization_exceptions=(*lexicon.capitalization_exceptions, (key, mask))) its two siblings offer. Updated the two tests that pinned the old text, which also type-check the pasted spelling. New test_the_mask_error_offers_code_that_adds_the_mask_and_keeps_the_rest evals the offered code and checks that it adds the mask and keeps the rest.
Outcome, Side, Signal members, CrossRoleMatch.left_role/right_role, MatchResult.left_alternative/right_alternative, LexiconReading fields not rendered Fixed with one #: line per member and field, worded from docs/matching.rst and docs/suggest.rst. LexiconReading's per-field prose moved out of its class docstring into the #: lines. The same family had more unrendered fields, now documented too: every RoleMatch, CrossRoleMatch and MatchResult field, SettingEvidence's four counts, by_signal and note, and Suggestion.evidence/names. modules.html now shows every one, and a full -E HTML build gives no warning.
_lexicon.py comment over _VOCAB_FIELDS: "add()/remove() operate on exactly these" Fixed: since 4i-b only the two lists are fields, and add()/remove() take a word and a kind.
_render.initials: "First letter of each contributing token" Fixed: one letter per letter of a run of initials (rules/R3, #1296).
_parser.py module docstring layering line Fixed: names _match, _suggest and _reading_index as call-time imports.
Lexicon.add docstring: unbalanced ")" and a dangling clause after spelling_of Fixed (sentences split).

Pipeline comments whose example no longer reads as stated

Site Done
_post_rules.py R1 roles note: 'Smith, MD nee Jones PhD' one entry Fixed: 'Smith, MD (nee Jones) PhD' (suffix MD PhD, maiden Jones).
_assign.py given-walk comment: 'Andrews, M.D.' Fixed: dropped; it reads two initials now (C16, #1302). 'Smith, Dr. Jr.' still makes the point (v1 1.4.0: first Jr.).
_assemble.py: 'Hasan' in 'bin Ahmad Jr. Hasan, Ali' Fixed: 'bin Ahmad III Hasan, Ali' (family bin Ahmad Hasan, suffix III).
_pieces.segment_suffix_reading: 'Smith, A.B.' -> given 'A.B.' Fixed: 'Smith, XYZ' -> given 'XYZ' (a shape word with one name word before the comma, so licensed stays empty).
_pieces.py: 'Pedro Junior fils' keeps family 'fils' Fixed: 'Pedro Jnr fils', as decisions/S11 has it.
_pieces.py: 'doe, jane v phd do' reads suffix 'v phd do' Fixed: suffix 'phd do' (middle v).
_pieces.starts_a_credential_run: 'John Smith Ph. D. Jones' still reads family 'Jones' Fixed: run_start starts the run behind the merged piece itself (#827), so it reads suffix Ph. D. Jones.
_post_rules.py M4 gap note: Dean of Chemistry née Jones Fixed: same gap shown with Dr. Mary and Jane (family) against Mary and Jane née Jones (given Mary and Jane).
_assign.py: 'Smith, John PhD I.' keeps suffix 'PhD, I.' Fixed: 'PhD I.'.
_vocab.py: "__post_init__'s gate_bypassed check" Fixed: names check 4 of the vocabulary build (one suffix kind per word), which _lexicon._check_pool runs on a caller's reading too.
_pipeline/__init__.py: runners "arrive in 2.x minors" Fixed (stated without a release).

Stage headers

These were corrected against a runtime trace of each stage's Lexicon/Policy reads over every case row (the auditor's trace.py, re-run on this tree), plus a call-stack trace naming the helper each read went through.

  • _tokenize: Consumes and Produces now say that it rewrites extract's UNBALANCED_DELIMITER reports from a character offset to a token index. Implements gains N1 (the comma inside a clause).
  • _extract Reads: adds honorific_tails (through period_joined_credential) and generation_words/honorific_words (through settles_a_member, as the suffix words that do not settle a member, rules/S1).
  • _segment Reads: names the suffix-vocabulary sets it reads (generation_words, honorific_words, title_case_name_words, honorific_tails). Implements gains C10.
  • _classify Reads: surnames and honorific_tails are read, through in_any_wordlist and period_joined_credential. Adds saint_particles (through glued_saint_cut). Tags emitted: adds vocab:dotted-title. The list is now split by what assemble actually drops (_assemble._KIND_TAGS), so it no longer claims that vocab:title, vocab:particle-ambiguous, vocab:bound-given or vocab:given-abbreviation are dropped; they are published.
  • _group: Produces adds the PARTICLE_OR_GIVEN report the particle chain makes where the chained particle has only leading titles in front of it (St van Johnson, Freiherr von der Berg; Vincent van Gogh and Dr. Van Johnson report nothing at group), checked by stepping STAGES. The "group's own" line now names all four piece predicates. Implements gains P13 and C10.
  • _assign: Consumes adds extracted. Reads names the four suffix sets read through is_suffix_lenient (_reads_as_a_trailing_suffix). Implements gains H9, H10, C9, P9, S8 and S12.
  • _post_rules Reads: adds honorific_tails, generation_words and honorific_words to the S1 list. Implements gains P11, R10, R11 and W5's surname pair.
  • _match.py docstring: adds _lexicon._fold, _forms and FULL_STOPS to its import list.

Left alone, for the owner of docs/design/ to weigh (no rule file was edited here):

  • Each Implements line above gained exactly the IDs the findings named, and each was checked against the rule's implemented: footer. The footers name more modules than implement a rule, though: some modules only cite a rule where they ask its predicate. Footers naming a module whose header does not list the rule:
    • _classify: C10, H2, H5, H8, H9, H10, P7, P8, P12, R8, R9, S1–S4, S9, S11, S12, T4. Classify has no Implements line at all.
    • _group: C2, H5, M3, S4, S10, S12.
    • _assign: A1, C1, C2, P2, P3, P11, S5, S6, S9.
    • _post_rules: P2, P3, P5, P12, R2, R3.
  • Not reproduced on the case rows, so left as written:
    • _script_segment's header says it reads conjunctions DIRECTLY; the trace saw no such read over the case rows.
    • _assign's header lists given_name_titles (the alternative's P5 licence); the trace saw no read there either.

Verification

  • uv run pytest: 49,788 passed, 45 skipped, 3 xfailed. uv run pytest -n0 -m serial: 38 passed, 49836 deselected in 63.85s (0:01:03).
  • uv run mypy: no issues in 166 files. uv run ruff check: clean.
  • sphinx-build -E -b html: no warnings. sphinx-build -E -b doctest: 1317 tests, 0 failures.
  • git diff --stat origin/master -- tools/differential nameparser/config: empty.

Every example reading a changed comment or docstring states:

ok   'Smith, MD "Doc" PhD' {'suffix': 'MD PhD', 'str': '"Doc" Smith, MD PhD'}
ok   'Smith, MD (nee Jones) PhD' {'suffix': 'MD PhD', 'maiden': 'Jones'}
ok   'Smith, Dr. Jr.' {'title': 'Dr.', 'suffix': 'Jr.'}
ok   'bin Ahmad III Hasan, Ali' {'family': 'bin Ahmad Hasan', 'suffix': 'III'}
ok   'Smith, XYZ' {'given': 'XYZ', 'family': 'Smith'}
ok   'Pedro Jnr fils' {'family': 'fils'}
ok   'doe, jane v phd do' {'middle': 'v', 'suffix': 'phd do'}
ok   'John Smith Ph. D. Jones' {'suffix': 'Ph. D. Jones'}
ok   'John Smith PhD Jones' {'suffix': 'PhD Jones'}
ok   'Dr. Mary and Jane' {'family': 'Mary and Jane'}
ok   'Mary and Jane née Jones' {'given': 'Mary and Jane', 'maiden': 'Jones'}
ok   'Smith, John PhD I.' {'suffix': 'PhD I.'}
ok   'JOSE E' {'kinds': {'order'}}
ok   'jose e phd' {'kinds': {'order'}}
ok   'rovira, i' {'kinds': set()}
ok   'St van Johnson' {'kinds': {'particle-or-given'}}
ok   'Dr. St van Johnson' {'kinds': {'particle-or-given'}}
ok   Policy(middle_as_family=True) initials_as_family True
ok   Policy(name_order=FAMILY_FIRST) initials_as_family None
ok   (NameEvidence('Kim Minjun, PhD', surname=FAMILY_FIRST, family_in_capitals=False), NameEvidence('Smith, John'))
ok   zh recipe 玍
ok   words(same_as='muhammad') ('md', 'mhd', 'moch', 'moh', 'mohd', 'muh')
ALL OK

Review round 1 (6ddccc1): five rewritten sentences corrected for mechanism (starts_a_credential_run is reached without a comma, through run_start, #827; check 4 runs in _check_pool; a member settled beside it is rules/S1's, and generation_words/honorific_words are the words that do not settle one; group's report is narrowed to a particle with only leading titles in front; _VOCAB_FIELDS names given_names as 3.0's and | concatenating the edit logs), plus nits. Re-checked: AST identical but the two messages, snapshot, citation, lexicon and pipeline tests, mypy, ruff, html build.

🤖 Generated with Claude Code

Section B of the 3.1 release sweep: prose inside nameparser/ that no
longer says what the tree does. No reading moves; the only executable
text changed is two messages.

- Messages: the after_particle refusal cites rules/P10 (the rule it
  names), not O7; the case-mask refusal offers the additive
  dataclasses.replace(..., (*lexicon.capitalization_exceptions, ...))
  its two siblings offer, since the old one-pair tuple dropped every
  shipped mask when pasted. A new test runs the offered code.
- Rendered docs: Parser.suggest's initials_as_family sentence (only a
  family-first base stands down), the zh pack's surname recipe (|, not
  add()), NameEvidence's comma clause, CONJUNCTION_OR_INITIAL's "not
  reported", Lexicon.words' example, Lexicon.add's parenthesis, and
  #: lines for every Outcome, Side and Signal member and the match,
  suggestion and LexiconReading fields, which the API page did not
  render.
- Pipeline comments whose example no longer reads as stated, each
  replaced by one the tree gives.
- Stage headers: Reads, Consumes, Produces, the classify tag list and
  Implements lines corrected against a runtime trace of each stage's
  reads over every case row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@derek73 derek73 added this to the 3.1 milestone Nov 16, 2026
@derek73 derek73 added docs Documentation fixes and updates internals Refactors and parse cost with no behavior change labels Nov 16, 2026
@derek73 derek73 self-assigned this Nov 16, 2026
derek73 added a commit that referenced this pull request Nov 16, 2026
PR #1439 corrects classify's Reads: line, so the checklist describes the
convention rather than quoting which fields that line excepts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review round on #1439:
- starts_a_credential_run IS reached without a comma: run_start asks
  it of the piece in front of a kept one, peel_walk having left the
  merged Ph./D. piece out (#827).
- check 4 (one suffix kind per word) runs in _lexicon._check_pool, not
  _make_edit.
- a member settled by a word beside it is rules/S1's, and
  generation_words and honorific_words are the suffix words that do NOT
  settle one (extract, segment and post_rules headers).
- group's PARTICLE_OR_GIVEN report is made only where the chained
  particle has nothing but leading titles in front of it.
- the _VOCAB_FIELDS comment: given_names is 3.0's, and | concatenates
  the edit logs.
- nits: a grammar slip in a test docstring, Lexicon.words' example no
  longer lists every spelling, a long line in Parser.suggest's
  docstring, and the new #: lines use the files' ``literal`` and
  :class: roles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@derek73
derek73 merged commit 512676b into master Nov 16, 2026
14 checks passed
@derek73
derek73 deleted the docs/sweep-code-prose branch November 16, 2026 18:00
derek73 added a commit that referenced this pull request Nov 16, 2026
…ck to the layering rule (#1438)

* Correct the AGENTS files, READMEs and pickle notes, and hold every pack to the layering rule

The 3.1 stale-prose sweep's section D. tests/v2/test_layering.py now
checks every module in nameparser/locales/ by a default rule (the four
base modules plus the pack's own private data module; a data module
imports nothing), with a completeness check over locales/ like the
pipeline's; until now 17 packs and _es_ar_given_names.py were checked by
nothing. tools/stage_reads.py traces the Lexicon and Policy reads of each
stage over the case table, which the release checklist's Reads: grep
cannot see through aliases and helpers. compare.py's baseline moves to
3.0.1. The prose corrections are listed in the PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Describe the Reads: set convention without quoting classify's header

PR #1439 corrects classify's Reads: line, so the checklist describes the
convention rather than quoting which fields that line excepts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Read relative imports in the layering guard; tighten the stage_reads tests

The import walker recorded node.module alone, so a relative import was
dropped or recorded as nothing: a pack writing `from .. import _parser`
passed, and _suggest.py, which imports only relatively, was checked by
nothing. It now resolves node.level against the module's package, with
rows for each form, a planted pack violation and a reachability probe on
_suggest.py; the contract finds no current violation with them resolved.
The locales completeness check lists the folder through pkgutil rather
than the glob the rule uses, and holds each module to its kind's rule.
stage_reads' tests pin a read only the row's policy causes and that the
traced fold assembles what Parser.parse gives. The release-log pickle
bullet is trimmed to its index form, and an attribution naming a person
in AGENTS.md is reworded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation fixes and updates internals Refactors and parse cost with no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant