Skip to content

feat: enhance _union_schema to support unions of all types handled by SlotGenerator#38

Merged
candleindark merged 1 commit intodandi:mainfrom
candleindark:enhs/union-schema-improvement
Mar 18, 2026
Merged

feat: enhance _union_schema to support unions of all types handled by SlotGenerator#38
candleindark merged 1 commit intodandi:mainfrom
candleindark:enhs/union-schema-improvement

Conversation

@candleindark
Copy link
Copy Markdown
Member

Summary

  • Implements _get_ase, which converts a subschema to an AnonymousSlotExpression by delegating to a sub-SlotGenerator and projecting the resulting SlotDefinition fields (excluding required, a slot-level property that doesn't belong in a constraint expression context)
  • Refactors _union_schema to use _get_ase instead of a hardcoded supported_type_choices dispatch, enabling union support for any type already handled by SlotGenerator (primitives, lists, models, etc.)
  • Updates test_union_schema: the Foo1 (Union[int, Bar1, str]) sub-case now asserts a correct any_of instead of an "unsupported" note; adds a Foo3 (Union[int, list[Bar1], list[str], Bar2]) sub-case

Closes #37

Test plan

  • hatch run test.py3.10:pytest tests/test_gen_linkml.py::TestSlotGenerator::test_union_schema -v
  • hatch run test.py3.10:pytest tests/

🤖 Generated with Claude Code

…nerator`

Implements `_get_ase` to convert a subschema to an `AnonymousSlotExpression`
by delegating to a sub-`SlotGenerator`, then projecting the resulting
`SlotDefinition` fields onto `AnonymousSlotExpression` (excluding `required`,
which is a slot-level property that does not belong in a constraint expression).

Refactors `_union_schema` to use `_get_ase` instead of a hardcoded
`supported_type_choices` dispatch, enabling support for any type already
handled by `SlotGenerator` (e.g. int, str, list[...], models).

Closes dandi#37

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@candleindark candleindark changed the title feat: enhance _union_schema to support all types handled by SlotGenerator feat: enhance _union_schema to support unions of all types handled by SlotGenerator Mar 18, 2026
@candleindark candleindark merged commit bc39342 into dandi:main Mar 18, 2026
13 checks passed
@candleindark candleindark deleted the enhs/union-schema-improvement branch March 18, 2026 22:20
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.

Enhance SlotGenerator._union_schema so that it supports union of many different types

1 participant