refactor: extract _with_flow_seq_fallback helper from append/extend_list#50
refactor: extract _with_flow_seq_fallback helper from append/extend_list#50nathanjmcdougall wants to merge 1 commit into
Conversation
|
Closing this — on reflection the helper is too shallow to justify the indirection. The function interface is clunky: callers still compute The original 9-12 line try/except blocks in �ppend and �xtend_list are straightforward and self-contained. The cost of the duplication is low; the cost of the indirection (lambda stack frames, split control flow, awkward parameter set) outweighs it. |
Addresses
doc/todo/flow-sequence-fallback-duplication.md.append()andextend_list()had identical try/except blocks: attempt the operation, catchPatchError, check forFLOW_SEQUENCEorNOT_A_SEQUENCE, fall back to get→mutate→replace. Extracted into_with_flow_seq_fallback(keys, patches, fallback_fn).insert()is unchanged — it usesBLOCK_SEQUENCE_EXPECTED(a single kind covering both the flow and non-sequence cases) and needs anisinstancecheck, so it doesn't fit the same pattern.Net: −22 lines,
appendandextend_listeach collapse to two lines.