Skip to content

Added support for Enum types in Pydantic models#3391

Merged
pingsutw merged 2 commits intomasterfrom
adil/fix-type-enum-v1
Feb 18, 2026
Merged

Added support for Enum types in Pydantic models#3391
pingsutw merged 2 commits intomasterfrom
adil/fix-type-enum-v1

Conversation

@AdilFayyaz
Copy link
Collaborator

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

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.80%. Comparing base (ba7dc6f) to head (83826a5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/core/type_engine.py 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ba7dc6f) and HEAD (83826a5). Click for more details.

HEAD has 49 uploads less than BASE
Flag BASE (ba7dc6f) HEAD (83826a5)
50 1
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pingsutw pingsutw merged commit 4ee6f75 into master Feb 18, 2026
56 of 58 checks passed
@welcome
Copy link

welcome bot commented Feb 18, 2026

Congrats on merging your first pull request! 🎉

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.

2 participants

Comments