Skip to content

repr(ParsedName) prints ['suffix-or-name', 'suffix-or-name'] for two different words #431

Closed

Description

@derek73

parse("John Smith MA V") reports what looks like the same ambiguity twice:

<ParsedName: [
    given: 'John'
    family: 'Smith'
    suffix: 'MA, V'
    ambiguities: ['suffix-or-name', 'suffix-or-name']
]>

They are not duplicates. They are two distinct Ambiguity objects about two different words, each with its own detail:

kind: suffix-or-name | tokens: ['V']  | detail: "'V' is a roman numeral, so it reads as a
    generational suffix; any other single letter there would be a middle initial"
kind: suffix-or-name | tokens: ['MA'] | detail: "'MA' written without periods is both a
    post-nominal and an ordinary name; read as a suffix rather than a name part"

ParsedName.__repr__ (nameparser/_types.py:606) renders [a.kind.value for a in self.ambiguities], discarding both the token and the detail.

The SUFFIX_OR_NAME docstring (nameparser/_types.py:372) states the contract this breaks in as many words:

Which name part was declined depends on position and name_order, so detail names it rather than the kind.

The cost is diagnostic rather than parse correctness, but the failure mode is bad in a specific way: a lossy repr reads as a double-emit bug in the emitter, which is where the investigation goes first.

Suggested: include the token, e.g. ambiguities: ['suffix-or-name: MA', 'suffix-or-name: V'], matching Ambiguity.__repr__, which already prints Ambiguity('suffix-or-name': 'V').

Activity

  1. added this to the v2.2 milestone on Aug 24, 2026
  2. self-assigned this
    on Aug 24, 2026
  3. added a commit that references this issue on Aug 29, 2026
    388f9f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions