feat: enhance _union_schema to support unions of all types handled by SlotGenerator#38
Merged
candleindark merged 1 commit intodandi:mainfrom Mar 18, 2026
Conversation
…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>
_union_schema to support all types handled by SlotGenerator_union_schema to support unions of all types handled by SlotGenerator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_get_ase, which converts a subschema to anAnonymousSlotExpressionby delegating to a sub-SlotGeneratorand projecting the resultingSlotDefinitionfields (excludingrequired, a slot-level property that doesn't belong in a constraint expression context)_union_schemato use_get_aseinstead of a hardcodedsupported_type_choicesdispatch, enabling union support for any type already handled bySlotGenerator(primitives, lists, models, etc.)test_union_schema: theFoo1(Union[int, Bar1, str]) sub-case now asserts a correctany_ofinstead of an "unsupported" note; adds aFoo3(Union[int, list[Bar1], list[str], Bar2]) sub-caseCloses #37
Test plan
hatch run test.py3.10:pytest tests/test_gen_linkml.py::TestSlotGenerator::test_union_schema -vhatch run test.py3.10:pytest tests/🤖 Generated with Claude Code