Repository navigation
Conversation
…comments A quality-only pass over the 3.0 cycle's changes to _parser, _policy and the locale packs; no behavior, message, repr or pickle changes. - cs, sk, es, es_ar: DEVIATES is deviates_by_two_family_names itself, not a wrapper whose docstring restated (and in cs and sk had let go stale) the shared helper's - parser_for: the per-pack tag check rewraps through _rewrapped, as the patch loop does (same text); the "one choice" comment moves to the loop it describes; rules/D2's second quote moves from above the warning re-emission to the apply_patch wrap it covers - _no_strict_language: `if locales:` for a loop that ran at most once - PolicyPatch: the comment naming every scalar field by name states the rule instead, so a new field cannot make it stale Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is not a bool Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Pass (c) of the three file-disjoint simplify passes before the 3.0.0 tag. It covers the 3.0 cycle's changes (
git diff v2.8.0 origin/master) tonameparser/_parser.py,_policy.py,_locale.pyandnameparser/locales/*.py. The generated given-name modules and zh.py's generated block are excluded, and no other library file is touched. It is quality only: no behavior, message, repr or pickle change.Changes
DEVIATES = deviates_by_two_family_namesreplaces four one-line wrappers. Their docstrings restated the shared helper's, and in cs and sk they had gone stale ("shared with the es pack", from before es_ar existed). The registry gate (test_locales.py) asks only for a callable, andtest_cs_and_sk_pack_contentscompares cs's, sk's and es's to the helper.parser_for:_rewrapped, as the patch loop already does. The text comes out the same,while applying locale 'x': <exc>, and both raise a plain ValueError.stricthandling.apply_patchwrap that it does. The re-emission block itself is unchanged._no_strict_language:if locales:replacesfor loc in locales[:1], a loop that ran at most once. The docstring's broken line is reflowed.PolicyPatch.__post_init__: a comment listed all eight scalar fields by name. It now states the rule instead (every field but the union ones,name_orderandscript_orders), so adding a field can't make it stale.Guard proof
tools/differential/snapshot.jsonl1d4368c3…), not re-recorded;test_snapshot.pypassescldr_agreement*.json,wikidata_native_agreement*.jsontools/in the diff)tests/v2/test_locales.pyincl.test_non_interference_each_packtest_reprs.py)parser_for(pack),parser_for(ES, PT_BR, CS),parser_for(PT, strict=True),Parser(),Policy(): repr identical to master (38 objects)PYTHONHASHSEED=0the pickle bytes are identical in both treestest_layering.py)-n0 -m serial)mypy,ruff checkConsidered and left alone
_locale._letter_runsonto_policy._script_matcher(reuse review). It would change whatDEVIATESdeclares: halfwidth katakana counts as one run today, and hangul jamo as two. That is a behavior change, so it's out of scope here.language_pack(code, tag)helper for the nine vocabulary-only packs (reuse review). It would save about three lines per pack, but each pack would stop being a plainLocale(...)literal, the form docs/locales.rst teaches contributors to write._with_packs(efficiency review). It saves under 1 ms per pack at construction, and nothing on the parse path._rewrappeddiscarding the exception subclass, and_failed_layer's error-path rebuild (altitude review). Both sit at the right depth. Anadd_noterewrite would change how the message renders.Policy's repr printssegment_scriptsin frozenset iteration order, which varies across processes (parser_for(locales.JA)'s repr differs between runs). It predates this PR; this is a note, not a fix.Behavior-changing candidates (not applied)
These simpler forms were raised and refused because each changes what something declares or raises. Corpus counts are over the 6,731 distinct names in
tools/differential/corpus*.jsonl(measured 2026-11-05 on this branch)._locale._letter_runstests CJK with_policy._script_matcher(*_SCRIPT_RANGES)instead ofunicodedata.name(ch).startswith(_CJK)(reuse review). One definition of "CJK" replaces two.deviates_by_two_family_namesflips for 4 of the 6,731 names.ヤマダ タロウ,タナカ. Johnandタロウ·ヤマダ, which_SCRIPT_RANGEScounts as katakana.김. 민준written in conjoining jamo, which_SCRIPT_RANGES' precomposed HANGUL span doesn't cover. This is the unsafe direction for the non-interference gate, so the rewrite would first need_SCRIPT_RANGESwidened to the jamo block, which is itself a behavior change for every script-conditional rule._parser._rewrappedkeeps the original exception and adds the pack's name withexc.add_note(...)instead of building a new plain TypeError/ValueError (altitude review).parser_for's three rewrap sites. The raised type becomes the original one (a_lexicon._MaskValueErrorsubclass would surface as itself), and "while applying locale 'x'" moves from the message's first line to a note printed under the traceback.str(exc)loses the prefix.while applying localewould all need to read__notes__.deviates_by_two_family_namescounts the name tokens of a parse instead of whitespace pieces and letter runs (altitude review). This would drop the hand copy of tokenizer and segmentation knowledge (rules/T1–T3, W1).parse()): 1,457 of the 6,731 names flip, every one from declared to undeclared, and none the other way.Signor Marco Rossi,Dumas VI, Jr.,John Smith (PhD, MBA),j nee Smith,কিশোৰ.DEVIATESpredicate cannot reach without importing the parser, a layering change.Reviews
_reading_index.selectedraises only plain ValueError at the per-pack check, so_rewrappedgives the same type, text and__cause__.if locales:is the same as the old one-pass loop. Nothing readsDEVIATES.__name__or__doc__. This reviewer had no shell and checked by reading; the guard runs above are the executed proof.catch_warnings(record=True)re-emission block is byte-identical.unlisted_caps_suffixesis aCapsSuffixes, validated by its own check rather than a bool check. Fixed in da22a5f. The other changes were confirmed: the moved comments now sit on the code they describe (the D2 quote's old spot sat overParser(...)construction, which is not wrapped), and the deletedDEVIATESdocstrings' facts survive in_locale.deviates_by_two_family_names. The reviewer also noted that pack modules do not render through autodoc (docs/modules.rstlists onlyget, available).script_orders, which also defers to apply time.Locale,PolicyorPolicyPatchfield or method changed, only a comment), test coverage (no test changed), design docs (nothing under docs/ or any AGENTS.md changed).🤖 Generated with Claude Code