Walk inheritance hierarchy before checking is_dataclass
in type_engine
#1239
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.
TL;DR
Swap steps 3 & 4 in
type_engine.py
to walk the inheritance hierarchy to check for a registeredTypeTransformer
before checkingis_dataclass
Type
Are all requirements met?
Complete description
We have internal tooling which generates dataclasses from OpenAPI specifications, which all include a
Generated
mixin and are guaranteed to have ato_dict
/from_dict
method. We'd like to register a singletype transformer for all classes which have theGenerated
mixin instead of taking an extra dependency ondataclass-json
; however, this isn't possible with the present implementation since the type engine checksis_dataclass
before walking the inheritance hierarchy to resolve the type transformer.This PR swaps this behavior so we can successfully detect a type transformer for
Generated
rather than falling back to the default dataclass serialization.See https://flyte-org.slack.com/archives/CREL4QVAQ/p1666049599823129 for more details/discussion
Tracking Issue
N/A
Follow-up issue
N/A