Skip to content

Commit

Permalink
update pydantic from v1 to v2. (#497)
Browse files Browse the repository at this point in the history
Ref #496
  • Loading branch information
tokuhirom authored Jul 25, 2023
1 parent 9b814a1 commit 7296de7
Show file tree
Hide file tree
Showing 271 changed files with 472 additions and 472 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
// need pydantic imports
if (!pydanticImports.isEmpty()) {
Map<String, String> item = new HashMap<>();
item.put("import", String.format(Locale.ROOT, "from pydantic import %s\n", StringUtils.join(pydanticImports, ", ")));
item.put("import", String.format(Locale.ROOT, "from pydantic.v1 import %s\n", StringUtils.join(pydanticImports, ", ")));
newImports.add(item);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re # noqa: F401
import io

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated{{#asyncio}}
from typing import overload, Optional, Union, Awaitable{{/asyncio}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations
from typing import Any, Dict, Optional
from pydantic import Field, StrictInt, StrictStr
from pydantic.v1 import Field, StrictInt, StrictStr

class ApiResponse:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import re # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated
from typing import overload, Optional, Union, Awaitable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import pprint
import re # noqa: F401
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic.v1 import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-model-imports}}
from typing import Any, List
from pydantic import StrictStr, Field
from pydantic.v1 import StrictStr, Field

{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import re # noqa: F401
from aenum import Enum, no_arg
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic.v1 import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}


class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {{{modelPackage}}}

{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic.v1 import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-model-imports}}
Expand Down Expand Up @@ -147,7 +147,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isArray}}
{{^items.isPrimitiveType}}
{{^items.isEnumOrRef}}
# override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in {{{name}}} (list)
_items = []
if self.{{{name}}}:
for _item in self.{{{name}}}:
Expand All @@ -160,7 +160,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#isMap}}
{{^items.isPrimitiveType}}
{{^items.isEnumOrRef}}
# override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict)
# override the default output from pydantic.v1 by calling `to_dict()` of each value in {{{name}}} (dict)
_field_dict = {}
if self.{{{name}}}:
for _key in self.{{{name}}}:
Expand All @@ -174,7 +174,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{^isContainer}}
{{^isPrimitiveType}}
{{^isEnumOrRef}}
# override the default output from pydantic by calling `to_dict()` of {{{name}}}
# override the default output from pydantic.v1 by calling `to_dict()` of {{{name}}}
if self.{{{name}}}:
_dict['{{{baseName}}}'] = self.{{{name}}}.to_dict()
{{/isEnumOrRef}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import pprint
import re # noqa: F401
{{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}}
{{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic.v1 import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}}
{{#vendorExtensions.x-py-model-imports}}
{{{.}}}
{{/vendorExtensions.x-py-model-imports}}
from typing import Any, List
from pydantic import StrictStr, Field
from pydantic.v1 import StrictStr, Field

{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]

Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/api/async_manage_audience.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated
from typing import overload, Optional, Union, Awaitable

from pydantic import Field, StrictBool, StrictInt, StrictStr, conint
from pydantic.v1 import Field, StrictBool, StrictInt, StrictStr, conint

from linebot.v3.audience.models.add_audience_to_audience_group_request import AddAudienceToAudienceGroupRequest
from linebot.v3.audience.models.audience_group_create_route import AudienceGroupCreateRoute
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/api/async_manage_audience_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated
from typing import overload, Optional, Union, Awaitable

from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, constr
from pydantic.v1 import Field, StrictBool, StrictBytes, StrictInt, StrictStr, constr

from typing import Optional, Union

Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/api/manage_audience.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import re # noqa: F401
import io

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictInt, StrictStr, conint
from pydantic.v1 import Field, StrictBool, StrictInt, StrictStr, conint

from linebot.v3.audience.models.add_audience_to_audience_group_request import AddAudienceToAudienceGroupRequest
from linebot.v3.audience.models.audience_group_create_route import AudienceGroupCreateRoute
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/api/manage_audience_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import re # noqa: F401
import io

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated

from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, constr
from pydantic.v1 import Field, StrictBool, StrictBytes, StrictInt, StrictStr, constr

from typing import Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion linebot/v3/audience/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations
from typing import Any, Dict, Optional
from pydantic import Field, StrictInt, StrictStr
from pydantic.v1 import Field, StrictInt, StrictStr

class ApiResponse:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist
from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr, conlist
from linebot.v3.audience.models.audience import Audience

class AddAudienceToAudienceGroupRequest(BaseModel):
Expand Down Expand Up @@ -57,7 +57,7 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of each item in audiences (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in audiences (list)
_items = []
if self.audiences:
for _item in self.audiences:
Expand Down
2 changes: 1 addition & 1 deletion linebot/v3/audience/models/audience.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictStr
from pydantic.v1 import BaseModel, Field, StrictStr

class Audience(BaseModel):
"""
Expand Down
2 changes: 1 addition & 1 deletion linebot/v3/audience/models/audience_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr
from pydantic.v1 import BaseModel, Field, StrictBool, StrictInt, StrictStr
from linebot.v3.audience.models.audience_group_create_route import AudienceGroupCreateRoute
from linebot.v3.audience.models.audience_group_failed_type import AudienceGroupFailedType
from linebot.v3.audience.models.audience_group_permission import AudienceGroupPermission
Expand Down
2 changes: 1 addition & 1 deletion linebot/v3/audience/models/audience_group_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr
from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr
from linebot.v3.audience.models.audience_group_job_failed_type import AudienceGroupJobFailedType
from linebot.v3.audience.models.audience_group_job_status import AudienceGroupJobStatus
from linebot.v3.audience.models.audience_group_job_type import AudienceGroupJobType
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/models/create_audience_group_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist, constr
from pydantic.v1 import BaseModel, Field, StrictBool, StrictStr, conlist, constr
from linebot.v3.audience.models.audience import Audience

class CreateAudienceGroupRequest(BaseModel):
Expand Down Expand Up @@ -58,7 +58,7 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of each item in audiences (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in audiences (list)
_items = []
if self.audiences:
for _item in self.audiences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, validator
from pydantic.v1 import BaseModel, Field, StrictBool, StrictFloat, StrictInt, StrictStr, validator
from linebot.v3.audience.models.audience_group_type import AudienceGroupType

class CreateAudienceGroupResponse(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictStr, constr
from pydantic.v1 import BaseModel, Field, StrictStr, constr

class CreateClickBasedAudienceGroupRequest(BaseModel):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator
from pydantic.v1 import BaseModel, Field, StrictBool, StrictInt, StrictStr, validator
from linebot.v3.audience.models.audience_group_type import AudienceGroupType

class CreateClickBasedAudienceGroupResponse(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictStr, constr
from pydantic.v1 import BaseModel, Field, StrictStr, constr

class CreateImpBasedAudienceGroupRequest(BaseModel):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr
from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr
from linebot.v3.audience.models.audience_group_type import AudienceGroupType

class CreateImpBasedAudienceGroupResponse(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion linebot/v3/audience/models/error_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, StrictStr
from pydantic.v1 import BaseModel, Field, StrictStr

class ErrorDetail(BaseModel):
"""
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/models/error_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist
from pydantic.v1 import BaseModel, Field, StrictStr, conlist
from linebot.v3.audience.models.error_detail import ErrorDetail

class ErrorResponse(BaseModel):
Expand Down Expand Up @@ -56,7 +56,7 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of each item in details (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in details (list)
_items = []
if self.details:
for _item in self.details:
Expand Down
6 changes: 3 additions & 3 deletions linebot/v3/audience/models/get_audience_data_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import List, Optional
from pydantic import BaseModel, Field, conlist
from pydantic.v1 import BaseModel, Field, conlist
from linebot.v3.audience.models.audience_group import AudienceGroup
from linebot.v3.audience.models.audience_group_job import AudienceGroupJob

Expand Down Expand Up @@ -57,10 +57,10 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of audience_group
# override the default output from pydantic.v1 by calling `to_dict()` of audience_group
if self.audience_group:
_dict['audienceGroup'] = self.audience_group.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in jobs (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in jobs (list)
_items = []
if self.jobs:
for _item in self.jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field
from linebot.v3.audience.models.audience_group_authority_level import AudienceGroupAuthorityLevel

class GetAudienceGroupAuthorityLevelResponse(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/audience/models/get_audience_groups_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, conlist
from pydantic.v1 import BaseModel, Field, StrictBool, StrictInt, conlist
from linebot.v3.audience.models.audience_group import AudienceGroup

class GetAudienceGroupsResponse(BaseModel):
Expand Down Expand Up @@ -60,7 +60,7 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of each item in audience_groups (list)
# override the default output from pydantic.v1 by calling `to_dict()` of each item in audience_groups (list)
_items = []
if self.audience_groups:
for _item in self.audience_groups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field
from linebot.v3.audience.models.audience_group_authority_level import AudienceGroupAuthorityLevel

class UpdateAudienceGroupAuthorityLevelRequest(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


from typing import Optional
from pydantic import BaseModel, Field, constr
from pydantic.v1 import BaseModel, Field, constr

class UpdateAudienceGroupDescriptionRequest(BaseModel):
"""
Expand Down
4 changes: 2 additions & 2 deletions linebot/v3/insight/api/async_insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import io
import warnings

from pydantic import validate_arguments, ValidationError
from pydantic.v1 import validate_arguments, ValidationError
from typing_extensions import Annotated
from typing import overload, Optional, Union, Awaitable

from pydantic import Field, constr, validator
from pydantic.v1 import Field, constr, validator

from typing import Optional

Expand Down
Loading

0 comments on commit 7296de7

Please sign in to comment.