Permissiblevalue enums (part 4): Pydanticgen - schema-element.generated-class registry#3600
Draft
noelmcloughlin wants to merge 5 commits into
Draft
Permissiblevalue enums (part 4): Pydanticgen - schema-element.generated-class registry#3600noelmcloughlin wants to merge 5 commits into
noelmcloughlin wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3600 +/- ##
===========================================
- Coverage 80.17% 36.69% -43.49%
===========================================
Files 157 157
Lines 18679 18726 +47
Branches 3935 3948 +13
===========================================
- Hits 14976 6871 -8105
- Misses 2868 11637 +8769
+ Partials 835 218 -617
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Wait for #3596, #3597, #3598, #3599
Summary
Architectural fixes #723 (part 4 of 4)
Before - The registry only works for pythongen output. Pydantic users (SSSOM-py, etc.) emit stdlib class X(str, Enum) enums, which never touched EnumDefinitionImpl._registry, so SchemaView.enum_class_for returned None for any pydantic-generated module.
After - A new module-level helper register_enum_class(schema_id, enum_name, cls) accepts any class object. pydanticgen attaches schema_id to each PydanticEnum, imports the helper, and emits register_enum_class("…", "EnumName", EnumName) lines after the enum block. SchemaView.enum_member_for dispatches on the registered class type - cls(pv) for EnumDefinitionImpl subclasses, cls(pv.text) for stdlib Enum subclasses - so consumers get a uniform SchemaView --> enum class / member lookup regardless of which generator produced the module.
How was this tested?
Added unit tests
Full suite testing
Areas of uncertainty
TBC
Checklist
AI Assistance
LLM assisted