Generalize custom type detection in nested Pydantic models#3396
Merged
AdilFayyaz merged 3 commits intomasterfrom Feb 19, 2026
Merged
Generalize custom type detection in nested Pydantic models#3396AdilFayyaz merged 3 commits intomasterfrom
AdilFayyaz merged 3 commits intomasterfrom
Conversation
Signed-off-by: M. Adil Fayyaz <62440954+AdilFayyaz@users.noreply.github.com>
pingsutw
approved these changes
Feb 19, 2026
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#664
Why are the changes needed?
Ensure flytekit is up to date with flytesdk
What changes were proposed in this pull request?
(JSON schema), nested custom types with registered TypeTransformers were being
rebuilt as generic dataclasses instead of being recognized as their original
types. This is because the schema reconstruction code never consulted
TypeEngine._REGISTRY for registered types when resolving $ref entries or inline
nested objects.
BaseModel subclasses by comparing JSON schema fingerprints (title, type,
required fields). No user override needed — registering a transformer for a
BaseModel subclass is sufficient.
registered transformers to find a match.
generate_attribute_list_from_dataclass_json_mixin,
_handle_json_schema_property, and _get_element_type with the generalized
helper, so any registered custom type is recognized before a synthetic
dataclass is created.
How was this patch tested?
pytest tests/flytekit/unit/core/test_custom_type_in_nested_pydantic.py — 7 new
tests covering _match_registered_type_from_schema (match, no match),
guess_python_type structure verification (direct, List, Dict, nested List), and
default schema_match behavior. Note: File/Dir schema match tests and the
mixed-type model test from v2 are not included because FlyteFile/FlyteDirectory
are not BaseModel subclasses in v1 and therefore do not benefit from the
auto-match logic.
Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link