Skip to content

Refactor(io): simplify format dispatch and reader/writer APIs - #357

Merged
balbasty merged 7 commits into
mainfrom
codex/refactor/io-reader-writer
Oct 9, 2026
Merged

balbasty merged 7 commits into
mainfrom
codex/refactor/io-reader-writer

Conversation

@balbasty

@balbasty balbasty commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

The I/O hierarchy mixed format selection with parsing and duplicated capabilities through file-based object wrappers. This change separates the contracts and removes redundant bases.

  • Format is the dispatcher and root registry for generic loading/saving. ImageFormat and TransformationFormat scope it to their domains. Dispatcher sniff* returns a selected class or None; it does not inherit the reader contract.
  • FileReader provides confidence-scoring sniff* and load/from_*; FileWriter independently provides save/to_*. Readers and dispatchers share private input adapters. Text and binary variants supply their adapters.
  • All 31 format-specific parser classes are named by capability: *Reader for reading, *ReaderWriter for both. Examples: MincReader, TfmTransformReader, NiftiReaderWriter, LtaReaderWriter. Their imports, exports, and documentation are updated without aliases.
  • The domain dispatchers carry no image/transformation fields; concrete objects supply their models. Field-free construction support preserves from_any, conversions, coordinate defaults, and constructor contracts. TransformationFormat also supplies the former hint marker's role.
  • Standalone families use @format_registry(isolated=True) to stop registration at their boundary. Nested registries still work, while their formats stay outside generic loading/saving. Export-only formats are excluded from reading candidates.

Breaking changes: remove all FileBased*/WritableFileBased* public wrappers and compatibility aliases. Use Format, ImageFormat, or TransformationFormat, with reader/writer composition. Generic *FileParser/*FileParserWriter and standalone sniffer bases are removed. Format-specific *Parser names are replaced by *Reader/*ReaderWriter. Migration guidance is documented.

Validation: 2,502 I/O, CLI, and constructor-signature tests passed (37 skipped). Tests cover dispatch versus reader sniff contracts, independent read/write inheritance, field-free domain dispatchers, export-only filtering, isolated/nested registries, coordinate defaults, and constructor contracts. Verified the capability-based names of all 31 format-specific classes. Ruff, formatting, codespell, and diff checks pass.

@balbasty balbasty changed the title Refactor(io): separate reader and writer capabilities Refactor(io): separate dispatch, reading and writing APIs Oct 9, 2026
@balbasty balbasty changed the title Refactor(io): separate dispatch, reading and writing APIs Refactor(io): simplify format dispatch and reader/writer APIs Oct 9, 2026
@balbasty
balbasty merged commit 42ae3b4 into main Oct 9, 2026
5 checks passed
@balbasty
balbasty deleted the codex/refactor/io-reader-writer branch October 9, 2026 15:37
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