Skip to content

Extract the FormatDispatcher mixin; accept non-tuple image indices - #309

Merged
balbasty merged 3 commits into
mainfrom
claude/refactor/233-format-dispatcher
Oct 6, 2026
Merged

balbasty merged 3 commits into
mainfrom
claude/refactor/233-format-dispatcher

Conversation

@balbasty

@balbasty balbasty commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Part of #233, split out of #287. Three small, independent commits:

  1. FormatDispatcher mixin. The dispatching sniff*/load/from_* methods move from FileBasedObject into a mixin that owns no registry. A kind of object that io.load must not return, such as file metadata further up the stack, can then dispatch among its own formats without landing in FileBasedObject's registry. Behaviour is unchanged, and test_io_mro.py is updated. The broader cleanup of dispatchers vs formats is Separate format dispatchers from concrete formats #297.
  2. Non-tuple index fix. SingleScaleImage.__getitem__ now accepts an index that isn't a tuple: img[::-1], img[1] and img[...] used to raise TypeError in Geometry.__getitem__. Its test uses metadata, so it lives in Wire format metadata into images and transformations (#233) #287.
  3. tx.Self annotations in datamodel/units.py.

Stack

  1. Design memo for the format-metadata framework #306: design memo
  2. Add vocabulary enums for spaces, intents, manufacturers and microscopy #307: vocabulary enums
  3. Add core helpers: shortest_decimal, EnumConverter, own_annotations #308: core helpers
  4. this PR: FormatDispatcher mixin and small fixes, based on main
  5. The metadata system, stacked on 1–4
  6. Wire format metadata into images and transformations (#233) #287: wiring, stacked on 5

🤖 Generated with Claude Code

https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw


Generated by Claude Code

claude added 3 commits October 6, 2026 05:04
…#233)

The dispatching behaviour of a class that owns a registry of formats
(the sniff*, load and from_* overrides) moves to FormatDispatcher, a
mixin that owns no registry itself. FileBasedObject is now the
registry-owning FormatDispatcher. A kind of object that the generic
load must not return, such as the metadata of a file, can then
dispatch among its own formats without being registered into the
registry of FileBasedObject. No behaviour changes; the MRO test checks
the overrides on FormatDispatcher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw
SingleScaleImage.__getitem__ handed a non-tuple index (img[::-1],
img[1], img[...]) to Geometry.__getitem__, which iterates over it and
raised TypeError. A single component is now wrapped in a tuple first,
as an index of the first axis.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw
The Unit constructors (__new__, _lookup, from_pint and the interning
lookup) and copies return an instance of the class they are called on.
Annotation only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw
@balbasty
balbasty merged commit 878668b into main Oct 6, 2026
5 checks passed
@balbasty
balbasty deleted the claude/refactor/233-format-dispatcher branch October 6, 2026 06:12
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.

2 participants