Skip to content

Commit

Permalink
[python] replace construct with model_construct
Browse files Browse the repository at this point in the history
  • Loading branch information
fa0311 committed Sep 21, 2023
1 parent ec6d661 commit 754c0e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return v

{{/isNullable}}
instance = {{{classname}}}.construct()
instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}()
error_messages = []
{{#composedSchemas.anyOf}}
# validate data type: {{{dataType}}}
Expand Down Expand Up @@ -121,7 +121,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
@classmethod
def from_json(cls, json_str: str) -> {{{classname}}}:
"""Returns the object represented by the json string"""
instance = {{{classname}}}.construct()
instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}()
{{#isNullable}}
if json_str is None:
return instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return v

{{/isNullable}}
instance = {{{classname}}}.construct()
instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}()
error_messages = []
match = 0
{{#composedSchemas.oneOf}}
Expand Down Expand Up @@ -124,7 +124,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
@classmethod
def from_json(cls, json_str: str) -> {{{classname}}}:
"""Returns the object represented by the json string"""
instance = {{{classname}}}.construct()
instance = {{{classname}}}.{{#usePydanticV2}}model_construct{{/usePydanticV2}}{{^usePydanticV2}}construct{{/usePydanticV2}}()
{{#isNullable}}
if json_str is None:
return instance
Expand Down

0 comments on commit 754c0e2

Please sign in to comment.