Closed jerber closed 3 years ago
new_user = User.construct(_fields_set=fields_set, **user_data) print(repr(new_user))
print(new_user.__fields_set__)
https://pydantic-docs.helpmanual.io/usage/models/#creating-models-without-validation
Maybe the default functionality of Pydantic (validates on constr) is desired. Have an arg for .get() in query that allows for forgiveness, in which case you use construct()
Done...
you can then create a new instance of User without
re-running validation which would be unnecessary at this point:
new_user = User.construct(_fields_set=fields_set, **user_data) print(repr(new_user))
> User(name='John Doe', id=123, age=32)
print(new_user.__fields_set__)
> {'age', 'id'}
https://pydantic-docs.helpmanual.io/usage/models/#creating-models-without-validation