-
Notifications
You must be signed in to change notification settings - Fork 222
[Bug]: Pydantic models with overridden Config fail to parse with extra=ignore #3066
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
It turns out that overriding Config in pydantic models breaks pydantic-duality extra=ignore parsing since Config overrides both Model.__request__.Config and Model.__response__.Config. As a result, adding new fields to models with custom Config leads to old client / new server incompatibility (and many models define custom schema_extra).
pydantic-duality supports defining common Config for all models via generate_dual_base_model(Config). As we want to also have a CoreModel with common config and methods, the fix would involve generating a custom base core model with custom config on the fly for every model that needs custom config:
class _BaseRunConfigurationConfig(CoreModel.Config):
@staticmethod
def schema_extra(schema: Dict[str, Any]):
...
class BaseRunConfiguration(generate_dual_core_model(_BaseRunConfigurationConfig)):
...
The inheritance approach should also be reworked so that mixin models do not inherit from CoreModel.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working