Closed khssnv closed 2 years ago
If you want to give it the name "Bar" you have to use it like this:
class Bar(pydantic_partial.create_partial_model(Foo)):
pass
Otherwise the function create_partial_model
will create a new model named FooPartial
which you stored under the variable name Bar
. Thats just how Python works actually 😉
I could add a parameter name
to the create_partial_model
function so you could do something like:
Bar = pydantic_partial.create_partial_model(Foo, name="Bar")
...would that follow what create_model
in pydantic allows. What do you think?
As no further questions did come up - I will close this issue.
Thank you for explanation. Inheriting from a partial model works for me :+1:
A
repr
call on a regular pydantic model returns a string likeModelName(param=value)
. For a model created bypydantic_partial.create_partial_model
it returnsParentModelNamePartial(param=value)
instead and misses the model name.