Skip to content

Add middle_name_as_last flag to fold middle names into last name (#133)#194

Merged
derek73 merged 5 commits into
masterfrom
worktree-middle-name-as-last
Jul 2, 2026
Merged

Add middle_name_as_last flag to fold middle names into last name (#133)#194
derek73 merged 5 commits into
masterfrom
worktree-middle-name-as-last

Conversation

@derek73

@derek73 derek73 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add opt-in middle_name_as_last flag to Constants, off by default and fully inert when unset (nameparser/config/__init__.py)
  • Add handle_middle_name_as_last() and wire it into post_process() (after patronymic_name_order handling, before capitalization) so middle_list folds into last_list, leaving .middle empty and .last equal to what .surnames already was
  • Document the flag in docs/customize.rst (bullet + "Suppressing Middle Names" subsection) and add an Unreleased bullet to docs/release_log.rst

Motivated 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.md
Implementation plan: docs/superpowers/plans/2026-07-01-middle-name-as-last.md

Test plan

  • uv run pytest — 1030 passed, 22 xfailed (pre-existing, unrelated), no regressions
  • uv run mypy nameparser/ — clean
  • uv run ruff check nameparser/ tests/ — clean
  • New tests/test_middle_name_as_last.py: fold (no-comma and comma convergence), title/suffix preservation, no-middle/single-token no-ops, given_names/surnames tracking the fold, last_prefixes interaction after folding, flag-off inertness
  • Verified both flags on (patronymic_name_order + middle_name_as_last) compose correctly by hand
  • Doc examples in docs/customize.rst verified against the real library output

🤖 Generated with Claude Code

derek73 and others added 5 commits July 1, 2026 19:08
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>
@derek73 derek73 self-assigned this Jul 2, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 2, 2026
@derek73 derek73 merged commit 5ea10c6 into master Jul 2, 2026
8 checks passed
@derek73 derek73 deleted the worktree-middle-name-as-last branch July 2, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant