Skip to content

Extract remaining write model helpers - #894

Merged
tompollard merged 1 commit into
mainfrom
refactor/explicit-write-helpers
Dec 3, 2026
Merged

tompollard merged 1 commit into
mainfrom
refactor/explicit-write-helpers

Conversation

@tompollard

Copy link
Copy Markdown
Member

Summary

Extract the last small helpers borrowed by _WriteModel for write-field selection, automatic signal file names, and overwrite warnings. The existing Record methods remain wrappers around the shared functions. The model now calls the field-selection and filename functions from its current metadata and has its own warning wrapper.

This is another internal step toward #866. Header and .dat encoding still use the inherited mixins; those are the next, larger steps. No public behavior or output change is intended.

Checks

  • 2,292 offline tests passed; 48 skipped and 23 network tests deselected.
  • Writer byte fixtures, header error parity, and overwrite warning caller tests passed (417 passed, 44 expected skips in the focused run).
  • New dependency tests fail on pre-change main and pass here.
  • 500 generated field-selection and filename cases matched pre-change main exactly.
  • Docs built with warnings treated as errors; Ruff and git diff --check passed.

No changelog entry because this only extracts internal helpers.

@tompollard tompollard left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, and it can merge. After it, _WriteModel borrows nothing from Record in its class body. The focused helper, fixture, parity and warning-location tests pass (417 passed, 44 expected skips), as do the offline suite (2,292 passed, 48 skipped) and Ruff.

What I checked, against main (dbe4195)

  • The moved code is unchanged. _auto_signal_file_names and _warn_about_replacing_other_files are line-for-line moves, with self. replaced by explicit arguments. The Record methods are now thin wrappers.
  • get_write_fields with a snapshot. This is the one path that changes implementation: with a snapshot it now uses the #875 field-selection functions instead of get_write_subset, and Record.set_defaults() goes through it. On 3,000 random Records, I compared the exact get_write_fields(snapshot) result (lists, dict and order) and _auto_signal_file_names() with main. The records had 1 to 19 channels, formats often sorted so groups form, many 508/516/524 channels to exercise the 8-channel and samples-per-frame group splits, and optional fields present or missing. All matched, including 2,010 multi-file groupings and 303 errors.
  • The public setters. My 4,000-record set_defaults()/set_default(field) comparison from #889 still matches main exactly, with the same digest and the same 812 expected errors.
  • The overwrite warning. For write_record, SignalRead.write, write_signals and the legacy Record.wrsamp, the warning text and the caller's file and line are identical to main.
  • The new tests fail on main. I copied tests/test_explicit_write_helpers.py into a main checkout: both fail there and pass here, unlike the ownership tests in #887 and #893.

The remaining dependencies are the inherited header and .dat encoders called from _write_prepared_files, which the description names as the next steps. When those land, the comparison against main will matter even more than here, since both write paths go through that shared code.

@tompollard
tompollard merged commit 9a79f42 into main Dec 3, 2026
19 checks passed
@tompollard
tompollard deleted the refactor/explicit-write-helpers branch December 3, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant