Add middle_name_as_last flag to fold middle names into last name (#133)#194
Merged
Conversation
Both flags on: post_process() runs the patronymic hook before the fold, so rotation should settle first/middle/last before the fold collapses middle into last. Also covers the subtler case where a comma suppresses rotation (_had_comma guard) but the fold still absorbs the unrotated middle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addresses remaining review suggestions: nickname stripping happens in pre_process() before the fold and should compose correctly; the comma-delimited suffix form exercises a different code path than the no-comma title/suffix case; single-token names should leave middle empty too, not just last, for consistency with the other no-op test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
middle_name_as_lastflag toConstants, off by default and fully inert when unset (nameparser/config/__init__.py)handle_middle_name_as_last()and wire it intopost_process()(afterpatronymic_name_orderhandling, before capitalization) somiddle_listfolds intolast_list, leaving.middleempty and.lastequal to what.surnamesalready wasdocs/customize.rst(bullet + "Suppressing Middle Names" subsection) and add an Unreleased bullet todocs/release_log.rstMotivated by #133 (Arabic patronymic chaining — given + father + grandfather + family has no middle-name concept; also helps #83 Chinese and #103 Portuguese naming).
Design doc:
docs/superpowers/specs/2026-06-30-middle-name-as-last-design.mdImplementation plan:
docs/superpowers/plans/2026-07-01-middle-name-as-last.mdTest plan
uv run pytest— 1030 passed, 22 xfailed (pre-existing, unrelated), no regressionsuv run mypy nameparser/— cleanuv run ruff check nameparser/ tests/— cleantests/test_middle_name_as_last.py: fold (no-comma and comma convergence), title/suffix preservation, no-middle/single-token no-ops,given_names/surnamestracking the fold,last_prefixesinteraction after folding, flag-off inertnesspatronymic_name_order+middle_name_as_last) compose correctly by handdocs/customize.rstverified against the real library output🤖 Generated with Claude Code