You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to generate some deeply nested models, and somewhere in the tree are fields defined as Optional[Exception]. Pydantic Factories doesn't have a handler for Exception. I'm not sure if that's intentional, but it creates a problem for me. I tried to override get_provider_map, but this didn't help because the field is in a nested model.
When a factory dynamically generates a new ModelFactory, the generated factory doesn't use the parent's overridden class methods. This makes it difficult or impossible to influence how those models are generated and resolve any errors in the process.
I was able to work around the issue by also overriding create_factory, so that generated factories will inherit from their parent in the hierarchy. If this is the preferred solution, then it would be great to have that documented. Otherwise, it would be good to have an option to enable that inheritance or otherwise pass on the top level get_provider_map.
Also, is it intentional that there's no provider for Exception?
Anyway, thank you this library is great and it's going to make my tests much more maintainable.
Issue
I'm trying to generate some deeply nested models, and somewhere in the tree are fields defined as
Optional[Exception]
. Pydantic Factories doesn't have a handler for Exception. I'm not sure if that's intentional, but it creates a problem for me. I tried to overrideget_provider_map
, but this didn't help because the field is in a nested model.When a factory dynamically generates a new ModelFactory, the generated factory doesn't use the parent's overridden class methods. This makes it difficult or impossible to influence how those models are generated and resolve any errors in the process.
I was able to work around the issue by also overriding
create_factory
, so that generated factories will inherit from their parent in the hierarchy. If this is the preferred solution, then it would be great to have that documented. Otherwise, it would be good to have an option to enable that inheritance or otherwise pass on the top levelget_provider_map
.Also, is it intentional that there's no provider for Exception?
Anyway, thank you this library is great and it's going to make my tests much more maintainable.
Workaround
The text was updated successfully, but these errors were encountered: