Skip to content

Add ConvertibleTo[Format] annotation - #162

Merged
tclose merged 1 commit into
mainfrom
convertible-types
Oct 13, 2026
Merged

tclose merged 1 commit into
mainfrom
convertible-types

Conversation

@tclose

@tclose tclose commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
  • ConvertibleTo[X] annotates "any format that can be converted to X"; it evaluates to X.convertible_from().
  • convertible_from() now returns Annotated[<union>, ConvertibleToMarker(X)], so the target format can be recovered from a hint with ConvertibleToMarker.from_hint(). Breaking: callers comparing against the bare union need to strip the annotation.
  • The union is sorted from most to least specific (subclasses before base classes) instead of by name.
  • to_mime/from_mime round-trip the hint as <namespace>/<format>+convertible-to (mime-like only), so the union is re-resolved from the converters installed where the string is read.
  • to_mime now passes official through for optional types.
  • LoadedMarker and ConvertibleToMarker share a new FormatMarker base.

… type can be converted to X using the registered converters
@tclose tclose changed the title adds ConvertibleTo[X] type (which is mime round-tripable) to mean any type can be converted to X using the registered converters Add ConvertibleTo[Format] annotation Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.37500% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fileformats/core/convertible.py 74.07% 4 Missing and 3 partials ⚠️
fileformats/core/identification.py 76.92% 1 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@tclose
tclose merged commit 11a8a42 into main Oct 13, 2026
19 checks passed
@tclose
tclose deleted the convertible-types branch October 14, 2026 03:53
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