Skip to content

Simplify join_on_conjunctions bookkeeping#207

Merged
derek73 merged 2 commits into
masterfrom
simplify/join-on-conjunctions
Jul 4, 2026
Merged

Simplify join_on_conjunctions bookkeeping#207
derek73 merged 2 commits into
masterfrom
simplify/join-on-conjunctions

Conversation

@derek73

@derek73 derek73 commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dedup the conjunction-index shift loop (two near-identical copies) into a single shift_conj_index helper.
  • Replace the pop() + try/except IndexError boundary check with an equivalent del pieces[i:i+rm_count] slice delete.
  • Replace pieces = pieces[:i] + [new_piece] + pieces[j:] slice-and-rebuild patterns with in-place slice assignment (pieces[i:j] = [new_piece]).

No behavior change intended — purely mechanical cleanup from a /simplify pass on join_on_conjunctions in nameparser/parser.py. Riskier suggestions (merging the i == 0/else branches, restructuring the value-based prefix .index() lookup, introducing a token-classification abstraction) were deliberately skipped since that logic was the root cause of a prior parsing bug (#100) and warrants separate, careful investigation rather than opportunistic refactoring.

Test plan

  • python -m pytest -q — 1248 passed, 4 skipped, 22 xfailed (same as before the change)

derek73 and others added 2 commits July 4, 2026 03:27
Dedup the conjunction-index shift loop into a shift_conj_index helper,
replace the pop()/try-except-IndexError boundary check with an
equivalent slice delete, and replace slice-and-rebuild list
reconstruction (pieces = pieces[:i] + [x] + pieces[j:]) with in-place
slice assignment. No behavior change; full test suite still passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR review flagged that the del-slice replacement for the old
pop()/try-except boundary check silently no-ops on an out-of-range
index instead of raising, unlike the original. That state is
currently unreachable, but add an assertion so a future regression
in the index bookkeeping fails loudly instead of silently corrupting
pieces.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jul 4, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 4, 2026
@derek73 derek73 merged commit 2951abf into master Jul 4, 2026
8 checks passed
@derek73 derek73 deleted the simplify/join-on-conjunctions branch July 4, 2026 10:32
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