Skip to content

Fix missing bound-first-name join in suffix-comma branch#205

Merged
derek73 merged 2 commits into
masterfrom
fix/bound-first-name-comma-branch
Jul 4, 2026
Merged

Fix missing bound-first-name join in suffix-comma branch#205
derek73 merged 2 commits into
masterfrom
fix/bound-first-name-comma-branch

Conversation

@derek73

@derek73 derek73 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • parse_full_name() calls _join_bound_first_name() in the no-comma branch (reserve_last=True) and the lastname-comma branch (reserve_last=False), but was missing the call in the suffix-comma branch (the parts[0] path taken when are_suffixes_after_comma is true).
  • Result: HumanName("Abdul Salam Hassan, MD") split the bound first name into first='Abdul', middle='Salam', while the equivalent no-comma ("Abdul Salam Hassan MD") and lastname-comma ("Hassan, Abdul Salam, MD") forms correctly produced first='Abdul Salam'.
  • Added the missing _join_bound_first_name(pieces, reserve_last=True) call at the suffix-comma call site, matching the no-comma branch's treatment of the same "title first middle last" token sequence.

Why not centralize the join inside parse_pieces()?

Considered moving the join into parse_pieces() itself, keyed off additional_parts_count, so callers wouldn't each need to remember to call it. Rejected: parse_pieces() is called with the same additional_parts_count value both for the post-comma given-names portion (which should get the join) and for the lastname portion in the lastname-comma branch (which must never get it, since it's surname text, not first-name text). Since the same parameter value means different things depending on which slice of the name is being parsed, doing this centrally would need extra context to disambiguate — no simpler than the current explicit per-call-site design, and riskier to get right. Documented this reasoning in AGENTS.md.

Changes

  • nameparser/parser.py: added the missing call in the suffix-comma branch.
  • tests/test_bound_first_names.py: added regression tests for the suffix-comma form (basic join, join-with-middle, two-token no-join guard).
  • AGENTS.md: updated the parse-flow notes to describe all three call sites and why the join isn't centralized.

Test plan

  • python -m pytest tests/test_bound_first_names.py -v — all pass, including new suffix-comma tests
  • python -m pytest -q — full suite passes (1238 passed, 4 skipped, 22 xfailed), no regressions
  • Manually verified all three equivalent input forms now agree: "Abdul Salam Hassan, MD", "Abdul Salam Hassan MD", "Hassan, Abdul Salam, MD"first='Abdul Salam'

🤖 Generated with Claude Code

parse_full_name() called _join_bound_first_name() in the no-comma and
lastname-comma branches but not in the suffix-comma branch, so
HumanName("Abdul Salam Hassan, MD") split the bound first name across
first/middle while the equivalent no-comma and lastname-comma forms of
the same name did not. Add the missing call and regression tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jul 4, 2026
@derek73 derek73 added the bug label Jul 4, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 4, 2026
Reviewer follow-ups on PR #205: add regression tests for title and
last-name-prefix interaction in the suffix-comma branch, mirroring
existing coverage for the no-comma branch, and split a run-on
sentence in AGENTS.md's parse-flow notes for readability.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@derek73 derek73 merged commit 76098cc into master Jul 4, 2026
8 checks passed
@derek73 derek73 deleted the fix/bound-first-name-comma-branch branch July 4, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant