Skip to content

Make bool(MatchResult) raise, name the method in Matching's non-name error, and say what a suggestion promises across releases - #1403

Merged
derek73 merged 4 commits into
masterfrom
claude/match-result-truth-value-a4510b
Nov 16, 2026
Merged

derek73 merged 4 commits into
masterfrom
claude/match-result-truth-value-a4510b

Conversation

@derek73

@derek73 derek73 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Three changes from the API review before the 3.1 release. Matching and the suggester have shipped in no release, so none of this moves a released behaviour.

1. bool(MatchResult) raises

A MatchResult defined no __bool__, so it was true for every pair: if matcher.check("John Smith", "Mary Jones"): took the branch on a conflict. MatchResult.__bool__ now raises TypeError:

a MatchResult has no truth value, got bool() of one whose consistent is False: a conflict is a result too, so `if result:` cannot mean a match; read its consistent field, e.g. parser.matching().check("John Smith", "J. Smith").consistent

Decided: raise, not return consistent. Shipping a truth value and changing it later would be a behaviour change; no working code depends on an exception, so raising keeps both open (decisions/name-matching, the name-matching decisions file, 2026-11-15 TRUTH VALUE).

Truthiness sites changed: none. Nothing in the library, tests, tools or docs relied on a result's truth value. Checked by the full suite with __bool__ raising (every assert on a result already read .consistent or compared with ==), both Sphinx builds, python -m doctest README.rst, and a read of every .check( outside tests/v2/test_match.py (tools/differential/match_diff.py reads r.consistent; tests/v2/test_parser.py, test_locales.py and test_familiar_tool.py read .consistent).

Tests: it raises on bool, not, and, a conditional, any and filter, for a consistent and a conflicting result; the offered code runs; ==, !=, hash, set and list membership, mirrored() and pickling still work, under other_readings too.

2. Matching.keys() names itself

matcher.keys(b"x") said "check takes a name string or a ParsedName". The shared _parsed takes the method's name. The test is parametrized over check (each argument) and keys, and four bad values. From review, not in the brief: bytes gets the decode hint Parser.parse gives (decode first, e.g. raw.decode('utf-8')), which the test runs.

3. What a suggestion promises across releases

docs/suggest.rst gains one paragraph, the counterpart of docs/matching.rst's "a key is a bucket of one nameparser version": what suggest() decides can change between releases as its tables and thresholds are tuned, so keep the settings applied (suggestion.patch, or suggestion.parser.policy) with the data. Suggestion's docstring says it in one sentence (it is the shorter of the two autodoc renders; Parser.suggest's is already long). Decisions entry: group-suggestion, 2026-11-15 ACROSS RELEASES.

4. The suggester's proposed statements are decided (added 2026-11-15, docs only)

Every statement in docs/design/decisions/group-suggestion.md marked "Proposed, for review" is accepted as written before 3.1. No code changes.

  • 24 markers removed (re-counted on base 17bc612): the lead on 12 Standing bullets (first letter capitalized, no other word changed), the marker on 11 entry heads, now (DECIDED BY 2026-11-15 ACCEPTED) (SCOPE, TABLES, SIGNALS, DECLINED, TURKIC, THRESHOLDS, FIX WAVE, TRAILING INITIAL, LETTER RUNS, CAPITALS, GIVEN NAMES FROM ORCID; TABLES reads "DECIDED THAT DAY; THE REST DECIDED BY…"), and one body sentence, SCOPE's closing "the rest of this file is proposed, for review", which now says it was. That one body edit is declared in the new entry; it was needed for the file to hold no such phrase.
  • A new entry, 2026-11-15 ACCEPTED, names the twelve by the entries they point at. Should Parser.suggest read AM Hoy as initials and a surname? A given-first byline list (AM Hoy, GH Yoon) is suggested FAMILY_FIRST #1355's head carried no marker; it gains a parenthetical, since its body called the reach "implementation and record, not decision" and the accepted Standing statement decides the part it words.
  • _MIN_PATRONYMIC_VOTES stays five; the Open paragraph is untouched.
  • Root AGENTS.md, Design philosophy: "as proposed for review in" becomes "as decided in … (accepted 2026-11-15)". No other site called the suggester's statements proposed: the other AGENTS.md files, docs/design/mechanisms.md, the RFC, other decisions files, docs/suggest.rst, the docstrings and the suggester's tools were read for paraphrases too.
  • For the maintainer: decisions/README.md allows four kinds of edit to an old entry "and no others"; replacing a head's status marker is none of them. It is declared in the ACCEPTED entry rather than added to the README as a fifth kind.

Also

  • Not decided, recorded in the TRUTH VALUE entry: a RoleMatch, a CrossRoleMatch and an Outcome stay truthy (Outcome.CONFLICT included).

  • docs/matching.rst: one paragraph and a doctest under "Checking a pair" for the raise, and a label matching-grouping-keys at "Grouping by key" for the new paragraph to link to.

  • Release log: no new bullet; a sentence and this PR's link folded into each of the two 3.1.0 bullets (Parser.matching(), Parser.suggest()).

  • tools/differential/snapshot.jsonl is byte-identical (no parse moves).

Checks

uv run pytest (48,676 passed), uv run pytest -n0 -m serial (38 passed), uv run mypy, uv run ruff check, sphinx-build -b doctest and -b html, and the suite on 3.15 in its own environment. Both Sphinx builds print nothing. Re-run after the fix commit.

Reviews

  • pr-review-toolkit:code-reviewer on the first commit: attacked the "no truthiness site" claim and found none; found the unguarded hint spelling, the missing bytes hint, the unlinked label and the undecided rows. All fixed or recorded.
  • design-docs-reviewer on the first commit's decisions entries: an over-wide universal in ACROSS RELEASES' Why, a Standing line wider than its entry, entries citing no PR, a bytearray arm parse() does not have. All fixed.
  • design-docs-reviewer on the acceptance commit: word-diff exact; Should Parser.suggest read AM Hoy as initials and a surname? A given-first byline list (AM Hoy, GH Yoon) is suggested FAMILY_FIRST #1355's body contradicted the accepted reach, and a miscounted sentence. Fixed.
  • design-docs-reviewer on the fix commit (dc6e5bc8), with a negative control on the bytes row: no defect in code or tests; three wording points in group-suggestion.md, fixed in 400c2e73 (docs only, not itself reviewed).

🤖 Generated with Claude Code

…error, and say what a suggestion promises across releases

A MatchResult defined no __bool__, so `if matcher.check(a, b):` took the
branch on a conflict. It now raises TypeError naming `.consistent`.
Matching.keys refused a non-name as "check takes ..."; the shared
_parsed names the method called. docs/suggest.rst and Suggestion's
docstring say a suggestion is one release's answer, so a caller keeps
the settings applied. Decisions entries in name-matching (TRUTH VALUE)
and group-suggestion (ACROSS RELEASES), both 2026-11-15.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@derek73 derek73 added this to the 3.1 milestone Nov 16, 2026
@derek73 derek73 added enhancement matching Name matching: Parser.matching(), check() and keys() suggester The group suggester: Parser.suggest() and its signals labels Nov 16, 2026
@derek73 derek73 self-assigned this Nov 16, 2026
derek73 and others added 3 commits November 15, 2026 17:02
decisions/group-suggestion: the "Proposed, for review" lead leaves the
twelve Standing bullets, the marker on eleven entry heads points at a
new 2026-11-15 ACCEPTED entry, and SCOPE's closing sentence says the
rest of the file was proposed. Root AGENTS.md's design philosophy says
the suggester's scope is decided. No code changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… spelling, and the decisions entries' claims narrowed

check() and keys() tell bytes to decode first, as parse() does. The
truth-value test holds the message to the spelling mypy checks. The
unlinked suggest-across-releases label goes. decisions: TRUTH VALUE
records that rows and outcomes stay truthy, undecided; ACROSS RELEASES
narrows its Standing line and its Why to what the entries show; ACCEPTED
says #1355's reach is a decision now and counts its heads right; each
new entry cites the PR.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… count

Second-round review of #1403: the reach decided is the part the
Standing statement words; the heads count names its population; ACROSS
RELEASES' Decided bullet names signals beside tables and thresholds.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@derek73
derek73 merged commit 63b3d0d into master Nov 16, 2026
14 checks passed
@derek73
derek73 deleted the claude/match-result-truth-value-a4510b branch November 16, 2026 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement matching Name matching: Parser.matching(), check() and keys() suggester The group suggester: Parser.suggest() and its signals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant