Added support for Enum types in Pydantic models#3391
Merged
Conversation
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3391 +/- ##
===========================================
- Coverage 82.87% 47.80% -35.07%
===========================================
Files 356 216 -140
Lines 29579 22782 -6797
Branches 2997 2998 +1
===========================================
- Hits 24513 10892 -13621
- Misses 4218 11295 +7077
+ Partials 848 595 -253 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pingsutw
approved these changes
Feb 18, 2026
|
Congrats on merging your first pull request! 🎉 |
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.
Tracking issue
Duplicated from: flyteorg/flyte-sdk/pull/622
Why are the changes needed?
Ensure flytekit versions alongside flytesdk
What changes were proposed in this pull request?
In
generate_attribute_list_from_dataclass_json_mixin(), when a $ref resolves to an enum definition (has enum key, no properties), map the field to str instead of trying to construct a dataclass from it. Previously this crashed with KeyError: 'properties' because the code assumed every $ref pointed to a model.How was this patch tested?
Test (test_enum_in_pydantic.py): Defines a Job(BaseModel) with a Status(str, Enum) field, roundtrips it through to_literal_type -> to_literal -> to_python_value -> guess_python_type, and verifies the guessed dataclass accepts enum values as strings.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link