diff --git a/.github/workflows/samples-python-client-echo-api.yaml b/.github/workflows/samples-python-client-echo-api.yaml index 8b073ac1897f..05ce58c4e45e 100644 --- a/.github/workflows/samples-python-client-echo-api.yaml +++ b/.github/workflows/samples-python-client-echo-api.yaml @@ -42,3 +42,7 @@ jobs: - name: Test working-directory: ${{ matrix.sample }} run: python -m pytest + + - name: mypy + working-directory: ${{ matrix.sample }} + run: python -m mypy diff --git a/.github/workflows/samples-python-petstore.yaml b/.github/workflows/samples-python-petstore.yaml index f6ec2e090071..4cf215d0c8d9 100644 --- a/.github/workflows/samples-python-petstore.yaml +++ b/.github/workflows/samples-python-petstore.yaml @@ -57,3 +57,7 @@ jobs: - name: Test working-directory: ${{ matrix.sample }} run: poetry run pytest -v + + - name: mypy + working-directory: ${{ matrix.sample }} + run: poetry run mypy diff --git a/bin/configs/python-aiohttp.yaml b/bin/configs/python-aiohttp.yaml index 6bec6d585b66..a7515a1bdfb2 100644 --- a/bin/configs/python-aiohttp.yaml +++ b/bin/configs/python-aiohttp.yaml @@ -6,3 +6,9 @@ library: asyncio additionalProperties: packageName: petstore_api mapNumberTo: float +nameMappings: + _type: underscore_type + type_: type_with_underscore +modelNameMappings: + # The OpenAPI spec ApiResponse conflicts with the internal ApiResponse + ApiResponse: ModelApiResponse diff --git a/bin/configs/python.yaml b/bin/configs/python.yaml index b13e5b802e21..09727cdfab9a 100644 --- a/bin/configs/python.yaml +++ b/bin/configs/python.yaml @@ -10,3 +10,6 @@ additionalProperties: nameMappings: _type: underscore_type type_: type_with_underscore +modelNameMappings: + # The OpenAPI spec ApiResponse conflicts with the internal ApiResponse + ApiResponse: ModelApiResponse diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index e7019bca8991..7f19be3e87e8 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -4,11 +4,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated {{#imports}} {{import}} diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 65637dd9786a..96e67add737e 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -280,15 +280,13 @@ class ApiClient: ) except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') raise e return response_data def response_deserialize( self, - response_data: rest.RESTResponse = None, + response_data: rest.RESTResponse, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -297,6 +295,8 @@ class ApiClient: :return: ApiResponse """ + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg response_type = response_types_map.get(str(response_data.status), None) if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: diff --git a/modules/openapi-generator/src/main/resources/python/api_response.mustache b/modules/openapi-generator/src/main/resources/python/api_response.mustache index 288b2e9a2543..9bc7c11f6b9f 100644 --- a/modules/openapi-generator/src/main/resources/python/api_response.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_response.mustache @@ -1,8 +1,8 @@ """API response object.""" from __future__ import annotations -from typing import Dict, Optional, Generic, TypeVar -from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel T = TypeVar("T") @@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache index bc1e8138c38e..7a902d4bbbb4 100644 --- a/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/asyncio/rest.mustache @@ -6,6 +6,7 @@ import io import json import re import ssl +from typing import Optional import aiohttp import aiohttp_retry @@ -72,6 +73,7 @@ class RESTClientObject: ) retries = configuration.retries + self.retry_client: Optional[aiohttp_retry.RetryClient] if retries is not None: self.retry_client = aiohttp_retry.RetryClient( client_session=self.pool_manager, diff --git a/modules/openapi-generator/src/main/resources/python/exceptions.mustache b/modules/openapi-generator/src/main/resources/python/exceptions.mustache index 82f9b7da0803..a690ceb926cb 100644 --- a/modules/openapi-generator/src/main/resources/python/exceptions.mustache +++ b/modules/openapi-generator/src/main/resources/python/exceptions.mustache @@ -2,7 +2,6 @@ {{>partial_header}} from typing import Any, Optional - from typing_extensions import Self class OpenApiException(Exception): diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 9a22937cd2c8..268a7cf1a408 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -11,6 +11,7 @@ import re # noqa: F401 {{/vendorExtensions.x-py-model-imports}} from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] @@ -27,7 +28,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} actual_instance: Optional[Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Literal[{{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS] + any_of_schemas: List[str] = Field(default=Literal[{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}]) model_config = { "validate_assignment": True, @@ -153,22 +154,20 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, {{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: - return "null" + return None - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - return json.dumps(self.actual_instance) + return self.actual_instance def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 7d300a1d3920..08a9de1dce31 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -9,10 +9,8 @@ import json {{#vendorExtensions.x-py-model-imports}} {{{.}}} {{/vendorExtensions.x-py-model-imports}} -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}): """ @@ -87,7 +85,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#hasChildren}} {{#discriminator}} # JSON field name that stores the object type - __discriminator_property_name: ClassVar[List[str]] = '{{discriminator.propertyBaseName}}' + __discriminator_property_name: ClassVar[str] = '{{discriminator.propertyBaseName}}' # discriminator mappings __discriminator_value_class_map: ClassVar[Dict[str, str]] = { @@ -95,7 +93,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} } @classmethod - def get_discriminator_value(cls, obj: Dict) -> str: + def get_discriminator_value(cls, obj: Dict) -> Optional[str]: """Returns the discriminator value (object type) of the data""" discriminator_value = obj[cls.__discriminator_property_name] if discriminator_value: @@ -115,7 +113,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> {{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}: + def from_json(cls, json_str: str) -> Optional[{{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}]: """Create an instance of {{{classname}}} from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -135,16 +133,18 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} * Fields in `self.additional_properties` are added to the output dict. {{/isAdditionalPropertiesTrue}} """ + excluded_fields: Set[str] = set([ + {{#vendorExtensions.x-py-readonly}} + "{{{.}}}", + {{/vendorExtensions.x-py-readonly}} + {{#isAdditionalPropertiesTrue}} + "additional_properties", + {{/isAdditionalPropertiesTrue}} + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - {{#vendorExtensions.x-py-readonly}} - "{{{.}}}", - {{/vendorExtensions.x-py-readonly}} - {{#isAdditionalPropertiesTrue}} - "additional_properties", - {{/isAdditionalPropertiesTrue}} - }, + exclude=excluded_fields, exclude_none=True, ) {{#allVars}} @@ -234,10 +234,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/allVars}} return _dict + {{#hasChildren}} @classmethod - def from_dict(cls, obj: Dict) -> {{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}: + def from_dict(cls, obj: Dict) -> Optional[{{#discriminator}}Union[{{#children}}Self{{^-last}}, {{/-last}}{{/children}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}]: """Create an instance of {{{classname}}} from a dict""" - {{#hasChildren}} {{#discriminator}} # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) @@ -249,8 +249,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) {{/discriminator}} - {{/hasChildren}} - {{^hasChildren}} + {{/hasChildren}} + {{^hasChildren}} + @classmethod + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: + """Create an instance of {{{classname}}} from a dict""" if obj is None: return None @@ -277,7 +280,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{^items.items.isPrimitiveType}} "{{{baseName}}}": [ [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] - for _item in obj.get("{{{baseName}}}") + for _item in obj["{{{baseName}}}"] ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} {{/items.items.isPrimitiveType}} {{/items.isArray}} @@ -287,7 +290,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} {{/items.isEnumOrRef}} {{^items.isEnumOrRef}} - "{{{baseName}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj.get("{{{baseName}}}")] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + "{{{baseName}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj["{{{baseName}}}"]] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} {{/items.isEnumOrRef}} {{/items.isPrimitiveType}} {{#items.isPrimitiveType}} @@ -320,14 +323,14 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if _v is not None else None ) - for _k, _v in obj.get("{{{baseName}}}").items() + for _k, _v in obj.get("{{{baseName}}}", {}).items() ){{^-last}},{{/-last}} {{/items.isArray}} {{/items.isContainer}} {{^items.isContainer}} "{{{baseName}}}": dict( (_k, {{{items.dataType}}}.from_dict(_v)) - for _k, _v in obj.get("{{{baseName}}}").items() + for _k, _v in obj["{{{baseName}}}"].items() ) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} @@ -345,7 +348,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{^isContainer}} {{^isPrimitiveType}} {{^isEnumOrRef}} - "{{{baseName}}}": {{{dataType}}}.from_dict(obj.get("{{{baseName}}}")) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} + "{{{baseName}}}": {{{dataType}}}.from_dict(obj["{{{baseName}}}"]) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} {{/isEnumOrRef}} {{#isEnumOrRef}} "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} @@ -370,7 +373,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/isAdditionalPropertiesTrue}} return _obj - {{/hasChildren}} + {{/hasChildren}} {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 0bd12fb44b5c..8ad253108081 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -22,7 +22,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} {{/composedSchemas.oneOf}} actual_instance: Optional[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]] = None - one_of_schemas: List[str] = Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] + one_of_schemas: List[str] = Field(default=Literal[{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}]) model_config = { "validate_assignment": True, @@ -175,19 +175,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/modules/openapi-generator/src/main/resources/python/pyproject.mustache b/modules/openapi-generator/src/main/resources/python/pyproject.mustache index f4e117c27958..2adaca6a3150 100644 --- a/modules/openapi-generator/src/main/resources/python/pyproject.mustache +++ b/modules/openapi-generator/src/main/resources/python/pyproject.mustache @@ -32,6 +32,9 @@ typing-extensions = ">=4.7.1" pytest = ">=7.2.1" tox = ">=3.9.0" flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + [build-system] requires = ["setuptools"] @@ -39,3 +42,10 @@ build-backend = "setuptools.build_meta" [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "{{{packageName}}}", + #"test", # auto-generated tests + "tests", # hand-written tests +] diff --git a/modules/openapi-generator/src/main/resources/python/rest.mustache b/modules/openapi-generator/src/main/resources/python/rest.mustache index f09988458595..99741f6ec004 100644 --- a/modules/openapi-generator/src/main/resources/python/rest.mustache +++ b/modules/openapi-generator/src/main/resources/python/rest.mustache @@ -61,56 +61,45 @@ class RESTClientObject: else: cert_reqs = ssl.CERT_NONE - addition_pool_args = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = ( + pool_args['assert_hostname'] = ( configuration.assert_hostname ) if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + pool_args['retries'] = configuration.retries if configuration.tls_server_name: - addition_pool_args['server_hostname'] = configuration.tls_server_name + pool_args['server_hostname'] = configuration.tls_server_name if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options + pool_args['socket_options'] = configuration.socket_options if configuration.connection_pool_maxsize is not None: - addition_pool_args['maxsize'] = configuration.connection_pool_maxsize + pool_args['maxsize'] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + if configuration.proxy: if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager - self.pool_manager = SOCKSProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) else: - self.pool_manager = urllib3.ProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) else: - self.pool_manager = urllib3.PoolManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) + self.pool_manager = urllib3.PoolManager(**pool_args) def request( self, diff --git a/modules/openapi-generator/src/main/resources/python/test-requirements.mustache b/modules/openapi-generator/src/main/resources/python/test-requirements.mustache index 3a0d0b939a1e..8e6d8cb13749 100644 --- a/modules/openapi-generator/src/main/resources/python/test-requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python/test-requirements.mustache @@ -1,3 +1,5 @@ pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py index 6089159d9dc4..c087929b7efe 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from openapi_client.api_client import ApiClient diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py index 0c3415d049e9..43e483a8c96b 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictStr from typing import Any, Dict, List, Optional, Union diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py index 55cbc8227e96..bab3edecb4f1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr from typing import Optional diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py index e69c88143848..962536dbeeda 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr, field_validator from typing import Optional diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py index d5ce74550480..5d41b588e424 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictInt, StrictStr, field_validator from openapi_client.models.string_enum_ref import StringEnumRef diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py index c0554ab3121c..328693f834b0 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from datetime import date, datetime from pydantic import StrictBool, StrictInt, StrictStr, field_validator diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py index 1c13bc4fbb5f..467a9f09c72a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py @@ -273,15 +273,13 @@ def call_api( ) except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') raise e return response_data def response_deserialize( self, - response_data: rest.RESTResponse = None, + response_data: rest.RESTResponse, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -290,6 +288,8 @@ def response_deserialize( :return: ApiResponse """ + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg response_type = response_types_map.get(str(response_data.status), None) if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_response.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_response.py index 288b2e9a2543..9bc7c11f6b9f 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_response.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_response.py @@ -1,8 +1,8 @@ """API response object.""" from __future__ import annotations -from typing import Dict, Optional, Generic, TypeVar -from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel T = TypeVar("T") @@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py index 4ddc870f3e0b..bd5561d241ed 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py @@ -13,7 +13,6 @@ """ # noqa: E501 from typing import Any, Optional - from typing_extensions import Self class OpenApiException(Exception): diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py index ff916fdb09dd..2de0078cf0f1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/bird.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Bird(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Bird from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Bird from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py index 49090ded8f0a..3e6f47997dc0 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/category.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Category(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Category from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py index ca54503ddfb1..4a89922e95d4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/data_query.py @@ -22,10 +22,8 @@ from pydantic import Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.query import Query -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DataQuery(Query): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DataQuery from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,16 +65,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DataQuery from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py index 64335035f5e4..7497228111a5 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/default_value.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.string_enum_ref import StringEnumRef -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DefaultValue(BaseModel): """ @@ -68,7 +66,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DefaultValue from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -82,10 +80,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if array_string_nullable (nullable) is None @@ -106,7 +106,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DefaultValue from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py index f45cf040f630..fe0a1f98c23b 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/number_properties_only.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, Field, StrictFloat, StrictInt from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NumberPropertiesOnly(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NumberPropertiesOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,16 +64,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NumberPropertiesOnly from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py index 84b464d88e8a..0507f2753b51 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/pet.py @@ -22,10 +22,8 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.category import Category from openapi_client.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Pet(BaseModel): """ @@ -66,7 +64,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,10 +78,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of category @@ -99,7 +99,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Pet from a dict""" if obj is None: return None @@ -115,9 +115,9 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name"), - "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, + "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, + "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, "status": obj.get("status") }) return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py index 7f3ba023a0eb..124c6d0cc993 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/query.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Query(BaseModel): """ @@ -61,7 +59,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Query from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,16 +73,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Dict) -> Optional[Self]: """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py index 62bdca916569..d66f29c8e50f 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/tag.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tag(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tag from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 6b8491fe9a3e..10b4a5b7deca 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,16 +64,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 7a31be0d568a..d4feba2b89c8 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/rest.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/rest.py index 5d0ca946c1f6..e1d6a981431d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/rest.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/rest.py @@ -72,56 +72,45 @@ def __init__(self, configuration) -> None: else: cert_reqs = ssl.CERT_NONE - addition_pool_args = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = ( + pool_args['assert_hostname'] = ( configuration.assert_hostname ) if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + pool_args['retries'] = configuration.retries if configuration.tls_server_name: - addition_pool_args['server_hostname'] = configuration.tls_server_name + pool_args['server_hostname'] = configuration.tls_server_name if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options + pool_args['socket_options'] = configuration.socket_options if configuration.connection_pool_maxsize is not None: - addition_pool_args['maxsize'] = configuration.connection_pool_maxsize + pool_args['maxsize'] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + if configuration.proxy: if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager - self.pool_manager = SOCKSProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) else: - self.pool_manager = urllib3.ProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) else: - self.pool_manager = urllib3.PoolManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) + self.pool_manager = urllib3.PoolManager(**pool_args) def request( self, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml index af471ab63148..9f72c3560d68 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/pyproject.toml @@ -21,6 +21,9 @@ typing-extensions = ">=4.7.1" pytest = ">=7.2.1" tox = ">=3.9.0" flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + [build-system] requires = ["setuptools"] @@ -28,3 +31,10 @@ build-backend = "setuptools.build_meta" [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "openapi_client", + #"test", # auto-generated tests + "tests", # hand-written tests +] diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test-requirements.txt b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test-requirements.txt index 3a0d0b939a1e..8e6d8cb13749 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test-requirements.txt +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test-requirements.txt @@ -1,3 +1,5 @@ pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/tests/__init__.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test/test_manual.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/tests/test_manual.py similarity index 100% rename from samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/test/test_manual.py rename to samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/tests/test_manual.py diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index 6089159d9dc4..c087929b7efe 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from openapi_client.api_client import ApiClient diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index 0c3415d049e9..43e483a8c96b 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictStr from typing import Any, Dict, List, Optional, Union diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 55cbc8227e96..bab3edecb4f1 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr from typing import Optional diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index e69c88143848..962536dbeeda 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictBool, StrictInt, StrictStr, field_validator from typing import Optional diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index d5ce74550480..5d41b588e424 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import StrictInt, StrictStr, field_validator from openapi_client.models.string_enum_ref import StringEnumRef diff --git a/samples/client/echo_api/python/openapi_client/api/query_api.py b/samples/client/echo_api/python/openapi_client/api/query_api.py index c0554ab3121c..328693f834b0 100644 --- a/samples/client/echo_api/python/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python/openapi_client/api/query_api.py @@ -15,11 +15,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from datetime import date, datetime from pydantic import StrictBool, StrictInt, StrictStr, field_validator diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index 1c13bc4fbb5f..467a9f09c72a 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -273,15 +273,13 @@ def call_api( ) except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') raise e return response_data def response_deserialize( self, - response_data: rest.RESTResponse = None, + response_data: rest.RESTResponse, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -290,6 +288,8 @@ def response_deserialize( :return: ApiResponse """ + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg response_type = response_types_map.get(str(response_data.status), None) if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: diff --git a/samples/client/echo_api/python/openapi_client/api_response.py b/samples/client/echo_api/python/openapi_client/api_response.py index 288b2e9a2543..9bc7c11f6b9f 100644 --- a/samples/client/echo_api/python/openapi_client/api_response.py +++ b/samples/client/echo_api/python/openapi_client/api_response.py @@ -1,8 +1,8 @@ """API response object.""" from __future__ import annotations -from typing import Dict, Optional, Generic, TypeVar -from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel T = TypeVar("T") @@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/samples/client/echo_api/python/openapi_client/exceptions.py b/samples/client/echo_api/python/openapi_client/exceptions.py index 4ddc870f3e0b..bd5561d241ed 100644 --- a/samples/client/echo_api/python/openapi_client/exceptions.py +++ b/samples/client/echo_api/python/openapi_client/exceptions.py @@ -13,7 +13,6 @@ """ # noqa: E501 from typing import Any, Optional - from typing_extensions import Self class OpenApiException(Exception): diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 35d5ad08d8bb..fe2835b56b04 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Bird(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Bird from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Bird from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index 9c93ae9497ee..919adb625f3a 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Category(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Category from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index 187cdbb3f11c..eb5ceeb0d941 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -22,10 +22,8 @@ from pydantic import Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.query import Query -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DataQuery(Query): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DataQuery from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,16 +65,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DataQuery from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 736af463f954..8f3c2663350c 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.string_enum_ref import StringEnumRef -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DefaultValue(BaseModel): """ @@ -68,7 +66,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DefaultValue from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -82,10 +80,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if array_string_nullable (nullable) is None @@ -106,7 +106,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DefaultValue from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 3fff7137780e..173479e3a7f2 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, Field, StrictFloat, StrictInt from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NumberPropertiesOnly(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NumberPropertiesOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,16 +64,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NumberPropertiesOnly from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 89c54fb4155d..9215a0bb0b3a 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -22,10 +22,8 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.category import Category from openapi_client.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Pet(BaseModel): """ @@ -66,7 +64,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,10 +78,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of category @@ -99,7 +99,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Pet from a dict""" if obj is None: return None @@ -110,9 +110,9 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "id": obj.get("id"), "name": obj.get("name"), - "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, + "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, + "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, "status": obj.get("status") }) return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 7f3ba023a0eb..124c6d0cc993 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Query(BaseModel): """ @@ -61,7 +59,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Query from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,16 +73,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Dict) -> Optional[Self]: """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index eff52563d287..be364cb1b1ed 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tag(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tag from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 47377d11bc90..9cf3cc47d81c 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,16 +64,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 326531ab6f75..8f8f4cb4de19 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" if obj is None: return None diff --git a/samples/client/echo_api/python/openapi_client/rest.py b/samples/client/echo_api/python/openapi_client/rest.py index 5d0ca946c1f6..e1d6a981431d 100644 --- a/samples/client/echo_api/python/openapi_client/rest.py +++ b/samples/client/echo_api/python/openapi_client/rest.py @@ -72,56 +72,45 @@ def __init__(self, configuration) -> None: else: cert_reqs = ssl.CERT_NONE - addition_pool_args = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = ( + pool_args['assert_hostname'] = ( configuration.assert_hostname ) if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + pool_args['retries'] = configuration.retries if configuration.tls_server_name: - addition_pool_args['server_hostname'] = configuration.tls_server_name + pool_args['server_hostname'] = configuration.tls_server_name if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options + pool_args['socket_options'] = configuration.socket_options if configuration.connection_pool_maxsize is not None: - addition_pool_args['maxsize'] = configuration.connection_pool_maxsize + pool_args['maxsize'] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + if configuration.proxy: if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager - self.pool_manager = SOCKSProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) else: - self.pool_manager = urllib3.ProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) else: - self.pool_manager = urllib3.PoolManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) + self.pool_manager = urllib3.PoolManager(**pool_args) def request( self, diff --git a/samples/client/echo_api/python/poetry.lock b/samples/client/echo_api/python/poetry.lock new file mode 100644 index 000000000000..7dfd40d63a77 --- /dev/null +++ b/samples/client/echo_api/python/poetry.lock @@ -0,0 +1,614 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "annotated-types" +version = "0.5.0" +description = "Reusable constraint types to use with typing.Annotated" +optional = false +python-versions = ">=3.7" +files = [ + {file = "annotated_types-0.5.0-py3-none-any.whl", hash = "sha256:58da39888f92c276ad970249761ebea80ba544b77acddaa1a4d6cf78287d45fd"}, + {file = "annotated_types-0.5.0.tar.gz", hash = "sha256:47cdc3490d9ac1506ce92c7aaa76c579dc3509ff11e098fc867e5130ab7be802"}, +] + +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.0" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "filelock" +version = "3.12.2" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.7" +files = [ + {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, + {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, +] + +[package.extras] +docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] + +[[package]] +name = "flake8" +version = "5.0.4" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.6.1" +files = [ + {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, + {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=1.1.0,<4.3", markers = "python_version < \"3.8\""} +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.9.0,<2.10.0" +pyflakes = ">=2.5.0,<2.6.0" + +[[package]] +name = "importlib-metadata" +version = "4.2.0" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.6" +files = [ + {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, + {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, +] + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + +[[package]] +name = "mypy" +version = "1.4.1" +description = "Optional static typing for Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mypy-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:566e72b0cd6598503e48ea610e0052d1b8168e60a46e0bfd34b3acf2d57f96a8"}, + {file = "mypy-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca637024ca67ab24a7fd6f65d280572c3794665eaf5edcc7e90a866544076878"}, + {file = "mypy-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0dde1d180cd84f0624c5dcaaa89c89775550a675aff96b5848de78fb11adabcd"}, + {file = "mypy-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8c4d8e89aa7de683e2056a581ce63c46a0c41e31bd2b6d34144e2c80f5ea53dc"}, + {file = "mypy-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:bfdca17c36ae01a21274a3c387a63aa1aafe72bff976522886869ef131b937f1"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7549fbf655e5825d787bbc9ecf6028731973f78088fbca3a1f4145c39ef09462"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:98324ec3ecf12296e6422939e54763faedbfcc502ea4a4c38502082711867258"}, + {file = "mypy-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:141dedfdbfe8a04142881ff30ce6e6653c9685b354876b12e4fe6c78598b45e2"}, + {file = "mypy-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8207b7105829eca6f3d774f64a904190bb2231de91b8b186d21ffd98005f14a7"}, + {file = "mypy-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:16f0db5b641ba159eff72cff08edc3875f2b62b2fa2bc24f68c1e7a4e8232d01"}, + {file = "mypy-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:470c969bb3f9a9efcedbadcd19a74ffb34a25f8e6b0e02dae7c0e71f8372f97b"}, + {file = "mypy-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5952d2d18b79f7dc25e62e014fe5a23eb1a3d2bc66318df8988a01b1a037c5b"}, + {file = "mypy-1.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:190b6bab0302cec4e9e6767d3eb66085aef2a1cc98fe04936d8a42ed2ba77bb7"}, + {file = "mypy-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9d40652cc4fe33871ad3338581dca3297ff5f2213d0df345bcfbde5162abf0c9"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:01fd2e9f85622d981fd9063bfaef1aed6e336eaacca00892cd2d82801ab7c042"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2460a58faeea905aeb1b9b36f5065f2dc9a9c6e4c992a6499a2360c6c74ceca3"}, + {file = "mypy-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2746d69a8196698146a3dbe29104f9eb6a2a4d8a27878d92169a6c0b74435b6"}, + {file = "mypy-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ae704dcfaa180ff7c4cfbad23e74321a2b774f92ca77fd94ce1049175a21c97f"}, + {file = "mypy-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:43d24f6437925ce50139a310a64b2ab048cb2d3694c84c71c3f2a1626d8101dc"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c482e1246726616088532b5e964e39765b6d1520791348e6c9dc3af25b233828"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:43b592511672017f5b1a483527fd2684347fdffc041c9ef53428c8dc530f79a3"}, + {file = "mypy-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:34a9239d5b3502c17f07fd7c0b2ae6b7dd7d7f6af35fbb5072c6208e76295816"}, + {file = "mypy-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5703097c4936bbb9e9bce41478c8d08edd2865e177dc4c52be759f81ee4dd26c"}, + {file = "mypy-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:e02d700ec8d9b1859790c0475df4e4092c7bf3272a4fd2c9f33d87fac4427b8f"}, + {file = "mypy-1.4.1-py3-none-any.whl", hash = "sha256:45d32cec14e7b97af848bddd97d85ea4f0db4d5a149ed9676caa4eb2f7402bb4"}, + {file = "mypy-1.4.1.tar.gz", hash = "sha256:9bbcd9ab8ea1f2e1c8031c21445b511442cc45c89951e49bbf852cbb70755b1b"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} +typing-extensions = ">=4.1.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +python2 = ["typed-ast (>=1.4.0,<2)"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "packaging" +version = "23.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] + +[[package]] +name = "platformdirs" +version = "2.6.2" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.7" +files = [ + {file = "platformdirs-2.6.2-py3-none-any.whl", hash = "sha256:83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490"}, + {file = "platformdirs-2.6.2.tar.gz", hash = "sha256:e1fea1fe471b9ff8332e229df3cb7de4f53eeea4998d3b6bfff542115e998bd2"}, +] + +[package.dependencies] +typing-extensions = {version = ">=4.4", markers = "python_version < \"3.8\""} + +[package.extras] +docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.5)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] + +[[package]] +name = "pluggy" +version = "1.2.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pluggy-1.2.0-py3-none-any.whl", hash = "sha256:c2fd55a7d7a3863cba1a013e4e2414658b1d07b6bc57b3919e0c63c9abb99849"}, + {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] + +[[package]] +name = "pycodestyle" +version = "2.9.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, + {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, +] + +[[package]] +name = "pydantic" +version = "2.5.3" +description = "Data validation using Python type hints" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydantic-2.5.3-py3-none-any.whl", hash = "sha256:d0caf5954bee831b6bfe7e338c32b9e30c85dfe080c843680783ac2b631673b4"}, + {file = "pydantic-2.5.3.tar.gz", hash = "sha256:b3ef57c62535b0941697cce638c08900d87fcb67e29cfa99e8a68f747f393f7a"}, +] + +[package.dependencies] +annotated-types = ">=0.4.0" +importlib-metadata = {version = "*", markers = "python_version == \"3.7\""} +pydantic-core = "2.14.6" +typing-extensions = ">=4.6.1" + +[package.extras] +email = ["email-validator (>=2.0.0)"] + +[[package]] +name = "pydantic-core" +version = "2.14.6" +description = "" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydantic_core-2.14.6-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:72f9a942d739f09cd42fffe5dc759928217649f070056f03c70df14f5770acf9"}, + {file = "pydantic_core-2.14.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6a31d98c0d69776c2576dda4b77b8e0c69ad08e8b539c25c7d0ca0dc19a50d6c"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5aa90562bc079c6c290f0512b21768967f9968e4cfea84ea4ff5af5d917016e4"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:370ffecb5316ed23b667d99ce4debe53ea664b99cc37bfa2af47bc769056d534"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f85f3843bdb1fe80e8c206fe6eed7a1caeae897e496542cee499c374a85c6e08"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9862bf828112e19685b76ca499b379338fd4c5c269d897e218b2ae8fcb80139d"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:036137b5ad0cb0004c75b579445a1efccd072387a36c7f217bb8efd1afbe5245"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:92879bce89f91f4b2416eba4429c7b5ca22c45ef4a499c39f0c5c69257522c7c"}, + {file = "pydantic_core-2.14.6-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:0c08de15d50fa190d577e8591f0329a643eeaed696d7771760295998aca6bc66"}, + {file = "pydantic_core-2.14.6-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:36099c69f6b14fc2c49d7996cbf4f87ec4f0e66d1c74aa05228583225a07b590"}, + {file = "pydantic_core-2.14.6-cp310-none-win32.whl", hash = "sha256:7be719e4d2ae6c314f72844ba9d69e38dff342bc360379f7c8537c48e23034b7"}, + {file = "pydantic_core-2.14.6-cp310-none-win_amd64.whl", hash = "sha256:36fa402dcdc8ea7f1b0ddcf0df4254cc6b2e08f8cd80e7010d4c4ae6e86b2a87"}, + {file = "pydantic_core-2.14.6-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:dea7fcd62915fb150cdc373212141a30037e11b761fbced340e9db3379b892d4"}, + {file = "pydantic_core-2.14.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ffff855100bc066ff2cd3aa4a60bc9534661816b110f0243e59503ec2df38421"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b027c86c66b8627eb90e57aee1f526df77dc6d8b354ec498be9a757d513b92b"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:00b1087dabcee0b0ffd104f9f53d7d3eaddfaa314cdd6726143af6bc713aa27e"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:75ec284328b60a4e91010c1acade0c30584f28a1f345bc8f72fe8b9e46ec6a96"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e1f4744eea1501404b20b0ac059ff7e3f96a97d3e3f48ce27a139e053bb370b"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b2602177668f89b38b9f84b7b3435d0a72511ddef45dc14446811759b82235a1"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6c8edaea3089bf908dd27da8f5d9e395c5b4dc092dbcce9b65e7156099b4b937"}, + {file = "pydantic_core-2.14.6-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:478e9e7b360dfec451daafe286998d4a1eeaecf6d69c427b834ae771cad4b622"}, + {file = "pydantic_core-2.14.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b6ca36c12a5120bad343eef193cc0122928c5c7466121da7c20f41160ba00ba2"}, + {file = "pydantic_core-2.14.6-cp311-none-win32.whl", hash = "sha256:2b8719037e570639e6b665a4050add43134d80b687288ba3ade18b22bbb29dd2"}, + {file = "pydantic_core-2.14.6-cp311-none-win_amd64.whl", hash = "sha256:78ee52ecc088c61cce32b2d30a826f929e1708f7b9247dc3b921aec367dc1b23"}, + {file = "pydantic_core-2.14.6-cp311-none-win_arm64.whl", hash = "sha256:a19b794f8fe6569472ff77602437ec4430f9b2b9ec7a1105cfd2232f9ba355e6"}, + {file = "pydantic_core-2.14.6-cp312-cp312-macosx_10_7_x86_64.whl", hash = "sha256:667aa2eac9cd0700af1ddb38b7b1ef246d8cf94c85637cbb03d7757ca4c3fdec"}, + {file = "pydantic_core-2.14.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cdee837710ef6b56ebd20245b83799fce40b265b3b406e51e8ccc5b85b9099b7"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c5bcf3414367e29f83fd66f7de64509a8fd2368b1edf4351e862910727d3e51"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:26a92ae76f75d1915806b77cf459811e772d8f71fd1e4339c99750f0e7f6324f"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a983cca5ed1dd9a35e9e42ebf9f278d344603bfcb174ff99a5815f953925140a"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cb92f9061657287eded380d7dc455bbf115430b3aa4741bdc662d02977e7d0af"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e4ace1e220b078c8e48e82c081e35002038657e4b37d403ce940fa679e57113b"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ef633add81832f4b56d3b4c9408b43d530dfca29e68fb1b797dcb861a2c734cd"}, + {file = "pydantic_core-2.14.6-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7e90d6cc4aad2cc1f5e16ed56e46cebf4877c62403a311af20459c15da76fd91"}, + {file = "pydantic_core-2.14.6-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:e8a5ac97ea521d7bde7621d86c30e86b798cdecd985723c4ed737a2aa9e77d0c"}, + {file = "pydantic_core-2.14.6-cp312-none-win32.whl", hash = "sha256:f27207e8ca3e5e021e2402ba942e5b4c629718e665c81b8b306f3c8b1ddbb786"}, + {file = "pydantic_core-2.14.6-cp312-none-win_amd64.whl", hash = "sha256:b3e5fe4538001bb82e2295b8d2a39356a84694c97cb73a566dc36328b9f83b40"}, + {file = "pydantic_core-2.14.6-cp312-none-win_arm64.whl", hash = "sha256:64634ccf9d671c6be242a664a33c4acf12882670b09b3f163cd00a24cffbd74e"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-macosx_10_7_x86_64.whl", hash = "sha256:24368e31be2c88bd69340fbfe741b405302993242ccb476c5c3ff48aeee1afe0"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:e33b0834f1cf779aa839975f9d8755a7c2420510c0fa1e9fa0497de77cd35d2c"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6af4b3f52cc65f8a0bc8b1cd9676f8c21ef3e9132f21fed250f6958bd7223bed"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d15687d7d7f40333bd8266f3814c591c2e2cd263fa2116e314f60d82086e353a"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:095b707bb287bfd534044166ab767bec70a9bba3175dcdc3371782175c14e43c"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94fc0e6621e07d1e91c44e016cc0b189b48db053061cc22d6298a611de8071bb"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ce830e480f6774608dedfd4a90c42aac4a7af0a711f1b52f807130c2e434c06"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a306cdd2ad3a7d795d8e617a58c3a2ed0f76c8496fb7621b6cd514eb1532cae8"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:2f5fa187bde8524b1e37ba894db13aadd64faa884657473b03a019f625cee9a8"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:438027a975cc213a47c5d70672e0d29776082155cfae540c4e225716586be75e"}, + {file = "pydantic_core-2.14.6-cp37-none-win32.whl", hash = "sha256:f96ae96a060a8072ceff4cfde89d261837b4294a4f28b84a28765470d502ccc6"}, + {file = "pydantic_core-2.14.6-cp37-none-win_amd64.whl", hash = "sha256:e646c0e282e960345314f42f2cea5e0b5f56938c093541ea6dbf11aec2862391"}, + {file = "pydantic_core-2.14.6-cp38-cp38-macosx_10_7_x86_64.whl", hash = "sha256:db453f2da3f59a348f514cfbfeb042393b68720787bbef2b4c6068ea362c8149"}, + {file = "pydantic_core-2.14.6-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3860c62057acd95cc84044e758e47b18dcd8871a328ebc8ccdefd18b0d26a21b"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:36026d8f99c58d7044413e1b819a67ca0e0b8ebe0f25e775e6c3d1fabb3c38fb"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8ed1af8692bd8d2a29d702f1a2e6065416d76897d726e45a1775b1444f5928a7"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:314ccc4264ce7d854941231cf71b592e30d8d368a71e50197c905874feacc8a8"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:982487f8931067a32e72d40ab6b47b1628a9c5d344be7f1a4e668fb462d2da42"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2dbe357bc4ddda078f79d2a36fc1dd0494a7f2fad83a0a684465b6f24b46fe80"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2f6ffc6701a0eb28648c845f4945a194dc7ab3c651f535b81793251e1185ac3d"}, + {file = "pydantic_core-2.14.6-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:7f5025db12fc6de7bc1104d826d5aee1d172f9ba6ca936bf6474c2148ac336c1"}, + {file = "pydantic_core-2.14.6-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:dab03ed811ed1c71d700ed08bde8431cf429bbe59e423394f0f4055f1ca0ea60"}, + {file = "pydantic_core-2.14.6-cp38-none-win32.whl", hash = "sha256:dfcbebdb3c4b6f739a91769aea5ed615023f3c88cb70df812849aef634c25fbe"}, + {file = "pydantic_core-2.14.6-cp38-none-win_amd64.whl", hash = "sha256:99b14dbea2fdb563d8b5a57c9badfcd72083f6006caf8e126b491519c7d64ca8"}, + {file = "pydantic_core-2.14.6-cp39-cp39-macosx_10_7_x86_64.whl", hash = "sha256:4ce8299b481bcb68e5c82002b96e411796b844d72b3e92a3fbedfe8e19813eab"}, + {file = "pydantic_core-2.14.6-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b9a9d92f10772d2a181b5ca339dee066ab7d1c9a34ae2421b2a52556e719756f"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fd9e98b408384989ea4ab60206b8e100d8687da18b5c813c11e92fd8212a98e0"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4f86f1f318e56f5cbb282fe61eb84767aee743ebe32c7c0834690ebea50c0a6b"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86ce5fcfc3accf3a07a729779d0b86c5d0309a4764c897d86c11089be61da160"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3dcf1978be02153c6a31692d4fbcc2a3f1db9da36039ead23173bc256ee3b91b"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eedf97be7bc3dbc8addcef4142f4b4164066df0c6f36397ae4aaed3eb187d8ab"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d5f916acf8afbcab6bacbb376ba7dc61f845367901ecd5e328fc4d4aef2fcab0"}, + {file = "pydantic_core-2.14.6-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:8a14c192c1d724c3acbfb3f10a958c55a2638391319ce8078cb36c02283959b9"}, + {file = "pydantic_core-2.14.6-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0348b1dc6b76041516e8a854ff95b21c55f5a411c3297d2ca52f5528e49d8411"}, + {file = "pydantic_core-2.14.6-cp39-none-win32.whl", hash = "sha256:de2a0645a923ba57c5527497daf8ec5df69c6eadf869e9cd46e86349146e5975"}, + {file = "pydantic_core-2.14.6-cp39-none-win_amd64.whl", hash = "sha256:aca48506a9c20f68ee61c87f2008f81f8ee99f8d7f0104bff3c47e2d148f89d9"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:d5c28525c19f5bb1e09511669bb57353d22b94cf8b65f3a8d141c389a55dec95"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:78d0768ee59baa3de0f4adac9e3748b4b1fffc52143caebddfd5ea2961595277"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b93785eadaef932e4fe9c6e12ba67beb1b3f1e5495631419c784ab87e975670"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a874f21f87c485310944b2b2734cd6d318765bcbb7515eead33af9641816506e"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b89f4477d915ea43b4ceea6756f63f0288941b6443a2b28c69004fe07fde0d0d"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:172de779e2a153d36ee690dbc49c6db568d7b33b18dc56b69a7514aecbcf380d"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:dfcebb950aa7e667ec226a442722134539e77c575f6cfaa423f24371bb8d2e94"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:55a23dcd98c858c0db44fc5c04fc7ed81c4b4d33c653a7c45ddaebf6563a2f66"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-macosx_10_7_x86_64.whl", hash = "sha256:4241204e4b36ab5ae466ecec5c4c16527a054c69f99bba20f6f75232a6a534e2"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e574de99d735b3fc8364cba9912c2bec2da78775eba95cbb225ef7dda6acea24"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1302a54f87b5cd8528e4d6d1bf2133b6aa7c6122ff8e9dc5220fbc1e07bffebd"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f8e81e4b55930e5ffab4a68db1af431629cf2e4066dbdbfef65348b8ab804ea8"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c99462ffc538717b3e60151dfaf91125f637e801f5ab008f81c402f1dff0cd0f"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e4cf2d5829f6963a5483ec01578ee76d329eb5caf330ecd05b3edd697e7d768a"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:cf10b7d58ae4a1f07fccbf4a0a956d705356fea05fb4c70608bb6fa81d103cda"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:399ac0891c284fa8eb998bcfa323f2234858f5d2efca3950ae58c8f88830f145"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c6a5c79b28003543db3ba67d1df336f253a87d3112dac3a51b94f7d48e4c0e1"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:599c87d79cab2a6a2a9df4aefe0455e61e7d2aeede2f8577c1b7c0aec643ee8e"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e166ad47ba900f2542a80d83f9fc65fe99eb63ceec4debec160ae729824052"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:3a0b5db001b98e1c649dd55afa928e75aa4087e587b9524a4992316fa23c9fba"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:747265448cb57a9f37572a488a57d873fd96bf51e5bb7edb52cfb37124516da4"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:7ebe3416785f65c28f4f9441e916bfc8a54179c8dea73c23023f7086fa601c5d"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:86c963186ca5e50d5c8287b1d1c9d3f8f024cbe343d048c5bd282aec2d8641f2"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:e0641b506486f0b4cd1500a2a65740243e8670a2549bb02bc4556a83af84ae03"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:71d72ca5eaaa8d38c8df16b7deb1a2da4f650c41b58bb142f3fb75d5ad4a611f"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27e524624eace5c59af499cd97dc18bb201dc6a7a2da24bfc66ef151c69a5f2a"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a3dde6cac75e0b0902778978d3b1646ca9f438654395a362cb21d9ad34b24acf"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:00646784f6cd993b1e1c0e7b0fdcbccc375d539db95555477771c27555e3c556"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:23598acb8ccaa3d1d875ef3b35cb6376535095e9405d91a3d57a8c7db5d29341"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7f41533d7e3cf9520065f610b41ac1c76bc2161415955fbcead4981b22c7611e"}, + {file = "pydantic_core-2.14.6.tar.gz", hash = "sha256:1fd0c1d395372843fba13a51c28e3bb9d59bd7aebfeb17358ffaaa1e4dbbe948"}, +] + +[package.dependencies] +typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" + +[[package]] +name = "pyflakes" +version = "2.5.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, + {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, +] + +[[package]] +name = "pytest" +version = "7.4.4" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "tox" +version = "3.28.0" +description = "tox is a generic virtualenv management and test command line tool" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ + {file = "tox-3.28.0-py2.py3-none-any.whl", hash = "sha256:57b5ab7e8bb3074edc3c0c0b4b192a4f3799d3723b2c5b76f1fa9f2d40316eea"}, + {file = "tox-3.28.0.tar.gz", hash = "sha256:d0d28f3fe6d6d7195c27f8b054c3e99d5451952b54abdae673b71609a581f640"}, +] + +[package.dependencies] +colorama = {version = ">=0.4.1", markers = "platform_system == \"Windows\""} +filelock = ">=3.0.0" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +packaging = ">=14" +pluggy = ">=0.12.0" +py = ">=1.4.17" +six = ">=1.14.0" +tomli = {version = ">=2.0.1", markers = "python_version >= \"3.7\" and python_version < \"3.11\""} +virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7" + +[package.extras] +docs = ["pygments-github-lexers (>=0.0.5)", "sphinx (>=2.0.0)", "sphinxcontrib-autoprogram (>=0.1.5)", "towncrier (>=18.5.0)"] +testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pathlib2 (>=2.3.3)", "psutil (>=5.6.1)", "pytest (>=4.0.0)", "pytest-cov (>=2.5.1)", "pytest-mock (>=1.10.0)", "pytest-randomly (>=1.0.0)"] + +[[package]] +name = "typed-ast" +version = "1.5.5" +description = "a fork of Python 2 and 3 ast modules with type comment support" +optional = false +python-versions = ">=3.6" +files = [ + {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"}, + {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"}, + {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"}, + {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"}, + {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"}, + {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"}, + {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"}, + {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"}, + {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"}, + {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"}, + {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"}, +] + +[[package]] +name = "types-python-dateutil" +version = "2.8.19.14" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = "*" +files = [ + {file = "types-python-dateutil-2.8.19.14.tar.gz", hash = "sha256:1f4f10ac98bb8b16ade9dbee3518d9ace017821d94b057a425b069f834737f4b"}, + {file = "types_python_dateutil-2.8.19.14-py3-none-any.whl", hash = "sha256:f977b8de27787639986b4e28963263fd0e5158942b3ecef91b9335c130cb1ce9"}, +] + +[[package]] +name = "typing-extensions" +version = "4.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[[package]] +name = "urllib3" +version = "2.0.7" +description = "HTTP library with thread-safe connection pooling, file post, and more." +optional = false +python-versions = ">=3.7" +files = [ + {file = "urllib3-2.0.7-py3-none-any.whl", hash = "sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e"}, + {file = "urllib3-2.0.7.tar.gz", hash = "sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84"}, +] + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.1.0)", "urllib3-secure-extra"] +socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] +zstd = ["zstandard (>=0.18.0)"] + +[[package]] +name = "virtualenv" +version = "20.16.2" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.6" +files = [ + {file = "virtualenv-20.16.2-py2.py3-none-any.whl", hash = "sha256:635b272a8e2f77cb051946f46c60a54ace3cb5e25568228bd6b57fc70eca9ff3"}, + {file = "virtualenv-20.16.2.tar.gz", hash = "sha256:0ef5be6d07181946891f5abc8047fda8bc2f0b4b9bf222c64e6e8963baee76db"}, +] + +[package.dependencies] +distlib = ">=0.3.1,<1" +filelock = ">=3.2,<4" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +platformdirs = ">=2,<3" + +[package.extras] +docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=21.3)"] +testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "packaging (>=20.0)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)"] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "e3db4fda1f09507e7001e5eccf6e0827b049b9384dba0fe21c7e1ff0a118503d" diff --git a/samples/client/echo_api/python/pyproject.toml b/samples/client/echo_api/python/pyproject.toml index af471ab63148..9f72c3560d68 100644 --- a/samples/client/echo_api/python/pyproject.toml +++ b/samples/client/echo_api/python/pyproject.toml @@ -21,6 +21,9 @@ typing-extensions = ">=4.7.1" pytest = ">=7.2.1" tox = ">=3.9.0" flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + [build-system] requires = ["setuptools"] @@ -28,3 +31,10 @@ build-backend = "setuptools.build_meta" [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "openapi_client", + #"test", # auto-generated tests + "tests", # hand-written tests +] diff --git a/samples/client/echo_api/python/test-requirements.txt b/samples/client/echo_api/python/test-requirements.txt index 3a0d0b939a1e..8e6d8cb13749 100644 --- a/samples/client/echo_api/python/test-requirements.txt +++ b/samples/client/echo_api/python/test-requirements.txt @@ -1,3 +1,5 @@ pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/samples/client/echo_api/python/tests/__init__.py b/samples/client/echo_api/python/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/echo_api/python/test/test_manual.py b/samples/client/echo_api/python/tests/test_manual.py similarity index 100% rename from samples/client/echo_api/python/test/test_manual.py rename to samples/client/echo_api/python/tests/test_manual.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 1ef5f596fa14..b85011e97909 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -12,7 +12,6 @@ docs/Animal.md docs/AnotherFakeApi.md docs/AnyOfColor.md docs/AnyOfPig.md -docs/ApiResponse.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md @@ -54,6 +53,7 @@ docs/MapOfArrayOfModel.md docs/MapTest.md docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/Model200Response.md +docs/ModelApiResponse.md docs/ModelReturn.md docs/Name.md docs/NullableClass.md @@ -116,7 +116,6 @@ petstore_api/models/all_of_with_single_ref.py petstore_api/models/animal.py petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.py -petstore_api/models/api_response.py petstore_api/models/array_of_array_of_model.py petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py @@ -155,6 +154,7 @@ petstore_api/models/map_of_array_of_model.py petstore_api/models/map_test.py petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/model200_response.py +petstore_api/models/model_api_response.py petstore_api/models/model_return.py petstore_api/models/name.py petstore_api/models/nullable_class.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 152c97aa2324..e9b47709917f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -146,7 +146,6 @@ Class | Method | HTTP request | Description - [Animal](docs/Animal.md) - [AnyOfColor](docs/AnyOfColor.md) - [AnyOfPig](docs/AnyOfPig.md) - - [ApiResponse](docs/ApiResponse.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) @@ -185,6 +184,7 @@ Class | Method | HTTP request | Description - [MapTest](docs/MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](docs/Model200Response.md) + - [ModelApiResponse](docs/ModelApiResponse.md) - [ModelReturn](docs/ModelReturn.md) - [Name](docs/Name.md) - [NullableClass](docs/NullableClass.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/ApiResponse.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md similarity index 55% rename from samples/openapi3/client/petstore/python-aiohttp/docs/ApiResponse.md rename to samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md index 866258d527c8..659823b8051f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ApiResponse.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md @@ -1,4 +1,4 @@ -# ApiResponse +# ModelApiResponse ## Properties @@ -12,19 +12,19 @@ Name | Type | Description | Notes ## Example ```python -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" -# create an instance of ApiResponse from a JSON string -api_response_instance = ApiResponse.from_json(json) +# create an instance of ModelApiResponse from a JSON string +model_api_response_instance = ModelApiResponse.from_json(json) # print the JSON string representation of the object -print ApiResponse.to_json() +print ModelApiResponse.to_json() # convert the object into a dict -api_response_dict = api_response_instance.to_dict() -# create an instance of ApiResponse from a dict -api_response_form_dict = api_response.from_dict(api_response_dict) +model_api_response_dict = model_api_response_instance.to_dict() +# create an instance of ModelApiResponse from a dict +model_api_response_form_dict = model_api_response.from_dict(model_api_response_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/PetApi.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PetApi.md index a5a475698949..5c94968b7caf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PetApi.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PetApi.md @@ -803,7 +803,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file** -> ApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) +> ModelApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) uploads an image @@ -815,7 +815,7 @@ uploads an image ```python import petstore_api -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.rest import ApiException from pprint import pprint @@ -862,7 +862,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ModelApiResponse.md) ### Authorization @@ -882,7 +882,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file_with_required_file** -> ApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) +> ModelApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) uploads an image (required) @@ -894,7 +894,7 @@ uploads an image (required) ```python import petstore_api -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.rest import ApiException from pprint import pprint @@ -941,7 +941,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ModelApiResponse.md) ### Authorization diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md index cd80b65dc0c0..0893df6055d0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md @@ -5,9 +5,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**underscore_type** | **str** | | [optional] **type** | **str** | | [optional] -**type** | **str** | | [optional] -**type_** | **str** | | [optional] +**type_with_underscore** | **str** | | [optional] ## Example diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index 72d39b9c55e6..f791bc531127 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -46,7 +46,6 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig -from petstore_api.models.api_response import ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly @@ -85,6 +84,7 @@ from petstore_api.models.map_test import MapTest from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.model_return import ModelReturn from petstore_api.models.name import Name from petstore_api.models.nullable_class import NullableClass diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index 2f279b0c9650..b6c2146619fb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index eb0fcccdc9ce..1edcdc9211f4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from petstore_api.models.foo_get_default_response import FooGetDefaultResponse diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index 3573e87fa700..5623c2606495 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictInt, StrictStr, field_validator diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index 00fe4e2e1898..6dc1e8a1e27e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 8def4b1717a0..361f23460a95 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -14,16 +14,12 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, field_validator from typing import List, Optional, Union from typing_extensions import Annotated -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.pet import Pet from petstore_api.api_client import ApiClient @@ -1976,7 +1972,7 @@ async def upload_file( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse: + ) -> ModelApiResponse: """uploads an image @@ -2020,7 +2016,7 @@ async def upload_file( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2051,7 +2047,7 @@ async def upload_file_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ApiResponse]: + ) -> ApiResponse[ModelApiResponse]: """uploads an image @@ -2095,7 +2091,7 @@ async def upload_file_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2170,7 +2166,7 @@ async def upload_file_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2277,7 +2273,7 @@ async def upload_file_with_required_file( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse: + ) -> ModelApiResponse: """uploads an image (required) @@ -2321,7 +2317,7 @@ async def upload_file_with_required_file( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2352,7 +2348,7 @@ async def upload_file_with_required_file_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ApiResponse]: + ) -> ApiResponse[ModelApiResponse]: """uploads an image (required) @@ -2396,7 +2392,7 @@ async def upload_file_with_required_file_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2471,7 +2467,7 @@ async def upload_file_with_required_file_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index f5db4f53a996..c6427c4dbdb9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictStr from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index 9666e87c9228..cc291571c075 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictStr from typing import List diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index e554eaf3da3f..3df0c6ddf22c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -275,15 +275,13 @@ async def call_api( ) except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') raise e return response_data def response_deserialize( self, - response_data: rest.RESTResponse = None, + response_data: rest.RESTResponse, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -292,6 +290,8 @@ def response_deserialize( :return: ApiResponse """ + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg response_type = response_types_map.get(str(response_data.status), None) if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_response.py index 288b2e9a2543..9bc7c11f6b9f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_response.py @@ -1,8 +1,8 @@ """API response object.""" from __future__ import annotations -from typing import Dict, Optional, Generic, TypeVar -from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel T = TypeVar("T") @@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py index 363d0d9f8744..0cb484becbdb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py @@ -12,7 +12,6 @@ """ # noqa: E501 from typing import Any, Optional - from typing_extensions import Self class OpenApiException(Exception): diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py index c106409daa97..945dd198de1a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py @@ -22,7 +22,6 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig -from petstore_api.models.api_response import ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly @@ -61,6 +60,7 @@ from petstore_api.models.map_test import MapTest from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.model_return import ModelReturn from petstore_api.models.name import Name from petstore_api.models.nullable_class import NullableClass diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index ffa1d02e5ad7..10dfc6f2e5cc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesAnyType(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesAnyType from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesAnyType from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index 947382b4651f..935697cc5c3b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesClass(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index e0bb54ce6b2e..12b382a288ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesObject(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesObject from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 3b9878cd05fb..7f2c44a9951b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index b2f8e7135cd8..bebb66fc5e10 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AllOfWithSingleRef(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AllOfWithSingleRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AllOfWithSingleRef from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index 29e4eba868d9..4c726e76978e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Animal(BaseModel): """ @@ -40,7 +38,7 @@ class Animal(BaseModel): # JSON field name that stores the object type - __discriminator_property_name: ClassVar[List[str]] = 'className' + __discriminator_property_name: ClassVar[str] = 'className' # discriminator mappings __discriminator_value_class_map: ClassVar[Dict[str, str]] = { @@ -48,7 +46,7 @@ class Animal(BaseModel): } @classmethod - def get_discriminator_value(cls, obj: Dict) -> str: + def get_discriminator_value(cls, obj: Dict) -> Optional[str]: """Returns the discriminator value (object type) of the data""" discriminator_value = obj[cls.__discriminator_property_name] if discriminator_value: @@ -66,7 +64,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union[Self, Self]: + def from_json(cls, json_str: str) -> Optional[Union[Self, Self]]: """Create an instance of Animal from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,16 +78,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Union[Self, Self]: + def from_dict(cls, obj: Dict) -> Optional[Union[Self, Self]]: """Create an instance of Animal from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index 18c98d1c1b84..f6252226ec20 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -22,6 +22,7 @@ from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -40,7 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Optional[Union[List[int], str]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS] + any_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) model_config = { "validate_assignment": True, @@ -133,22 +134,20 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, List[int], str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: - return "null" + return None - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - return json.dumps(self.actual_instance) + return self.actual_instance def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index afe139277b8a..6d730f25eb3b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -23,6 +23,7 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -39,7 +40,7 @@ class AnyOfPig(BaseModel): actual_instance: Optional[Union[BasquePig, DanishPig]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS] + any_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) model_config = { "validate_assignment": True, @@ -111,22 +112,20 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: - return "null" + return None - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - return json.dumps(self.actual_instance) + return self.actual_instance def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 96b3d6b87aec..c5c8d003babc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfArrayOfModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfArrayOfModel from a dict""" if obj is None: return None @@ -92,7 +92,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "another_property": [ [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj.get("another_property") + for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 3ab36ec64f86..a909381750b0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 6c81d802aad3..efe2d097b01c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfNumberOnly(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfNumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index 3cd94fd98560..a8f9771b60cb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayTest(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,10 +64,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) @@ -84,7 +84,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayTest from a dict""" if obj is None: return None @@ -97,7 +97,7 @@ def from_dict(cls, obj: Dict) -> Self: "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj.get("array_array_of_model") + for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index 7b308e9b94c0..d7a79efc2129 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class BasquePig(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of BasquePig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of BasquePig from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 9c5e93407ce0..f70bf0e5863d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Capitalization(BaseModel): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Capitalization from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,16 +65,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Capitalization from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 41755e5ec78d..9bfc4b55eeb8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -20,10 +20,8 @@ from pydantic import StrictBool from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Cat(Animal): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Cat from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Cat from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index 6ad5af9fc3d9..39a1eaa21eb8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Category(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Category from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index ea651c4d8bf6..cbb43ca55f64 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class CircularReferenceModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CircularReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of CircularReferenceModel from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 6d0ca1fe13b8..63428dfb6832 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ClassModel(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ClassModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ClassModel from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 908a28e29023..f0dea0fd33e5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Client(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Client from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Client from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index 09ef62c0d945..0e55bb3ac7c7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -35,7 +35,7 @@ class Color(BaseModel): # data type: str oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: List[str] = Literal["List[int]", "str"] + one_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) model_config = { "validate_assignment": True, @@ -144,19 +144,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, List[int], str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index 1c025c06ebbb..aebeed36cac4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List from petstore_api.models.creature_info import CreatureInfo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Creature(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Creature from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,10 +62,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of info @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Creature from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, + "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, "type": obj.get("type") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 4e95ba6fb53c..d85e978ae22d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class CreatureInfo(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CreatureInfo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of CreatureInfo from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index 1310d5bc0883..7bdb600bce1f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DanishPig(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DanishPig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DanishPig from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index 5a34663af800..a38ea178d5f2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DeprecatedObject(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DeprecatedObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DeprecatedObject from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index 04c77b83985f..f96107d73fe9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -20,10 +20,8 @@ from pydantic import StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Dog(Animal): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Dog from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Dog from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index ac5d12ea5785..42efb6e3117c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DummyModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DummyModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of self_ref @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DummyModel from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index acbe8dfa7a0f..a16343a4b1d4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class EnumArrays(BaseModel): """ @@ -70,7 +68,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of EnumArrays from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -84,16 +82,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of EnumArrays from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 77c92d0c4751..0534ab314ff3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -23,10 +23,8 @@ from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class EnumTest(BaseModel): """ @@ -107,7 +105,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of EnumTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -121,10 +119,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if outer_enum (nullable) is None @@ -135,7 +135,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of EnumTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index c8062e842dc3..dcf103963d6a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class File(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of File from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of File from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index ffd1c63ade4d..3a0e638014ba 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FileSchemaTestClass(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FileSchemaTestClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,10 +62,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of file @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FileSchemaTestClass from a dict""" if obj is None: return None @@ -92,8 +92,8 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None + "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, + "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index cbcfa274d843..d70194ab1fc0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FirstRef(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FirstRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of self_ref @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FirstRef from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index c3d05d2f6dc1..2f84abd8a72a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Foo(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Foo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Foo from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index 6db91273b0ba..0a062f61ec2e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FooGetDefaultResponse(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FooGetDefaultResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of string @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FooGetDefaultResponse from a dict""" if obj is None: return None @@ -84,7 +84,7 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None + "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index 42cc4409b462..dd3406c4896b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -22,10 +22,8 @@ from pydantic import BaseModel, Field, StrictBytes, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FormatTest(BaseModel): """ @@ -107,7 +105,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FormatTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -121,16 +119,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FormatTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index d4a5717c1686..ea81e325beb7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class HasOnlyReadOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of HasOnlyReadOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,18 +63,20 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. """ + excluded_fields: Set[str] = set([ + "bar", + "foo", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "bar", - "foo", - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of HasOnlyReadOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index 76ea4d607069..16577588e4e8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class HealthCheckResult(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of HealthCheckResult from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,10 +60,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if nullable_message (nullable) is None @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of HealthCheckResult from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index f0ca4b99a771..42ecd1c7d449 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class InnerDictWithProperty(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of InnerDictWithProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of InnerDictWithProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index b4309c791119..5153b87a311a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -33,7 +33,7 @@ class IntOrString(BaseModel): # data type: str oneof_schema_2_validator: Optional[StrictStr] = None actual_instance: Optional[Union[int, str]] = None - one_of_schemas: List[str] = Literal["int", "str"] + one_of_schemas: List[str] = Field(default=Literal["int", "str"]) model_config = { "validate_assignment": True, @@ -121,19 +121,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, int, str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index 62c2568653c0..dd7dd4c5ec4b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ListClass(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ListClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ListClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 90fe15449cbd..bbde411cf095 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MapOfArrayOfModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MapOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MapOfArrayOfModel from a dict""" if obj is None: return None @@ -96,7 +96,7 @@ def from_dict(cls, obj: Dict) -> Self: if _v is not None else None ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap").items() + for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() ) }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 226dc899718a..c35c19dd0d16 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MapTest(BaseModel): """ @@ -61,7 +59,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MapTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,16 +73,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MapTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index 154480cc7109..e04e2463c6cb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,10 +64,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in map (dict) @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" if obj is None: return None @@ -95,7 +95,7 @@ def from_dict(cls, obj: Dict) -> Self: "dateTime": obj.get("dateTime"), "map": dict( (_k, Animal.from_dict(_v)) - for _k, _v in obj.get("map").items() + for _k, _v in obj["map"].items() ) if obj.get("map") is not None else None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index c11b13979986..1d25f6bb1724 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Model200Response(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Model200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Model200Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py similarity index 82% rename from samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py rename to samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index d25f6c2c006e..d12375f6812c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -19,14 +19,12 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self -class ApiResponse(BaseModel): +class ModelApiResponse(BaseModel): """ - ApiResponse + ModelApiResponse """ # noqa: E501 code: Optional[StrictInt] = None type: Optional[StrictStr] = None @@ -50,8 +48,8 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ApiResponse from a JSON string""" + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ModelApiResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -64,17 +62,19 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ApiResponse from a dict""" + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: + """Create an instance of ModelApiResponse from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index eb5f36ac7bda..4a922832f97c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ModelReturn(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ModelReturn from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ModelReturn from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index b9d2532d45f4..6affde83bc72 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Name(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Name from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,18 +65,20 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * OpenAPI `readOnly` fields are excluded. """ + excluded_fields: Set[str] = set([ + "snake_case", + "var_123_number", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "snake_case", - "var_123_number", - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Name from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index ffa309c4191d..071950c74076 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -20,10 +20,8 @@ from datetime import date, datetime from pydantic import BaseModel, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NullableClass(BaseModel): """ @@ -62,7 +60,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NullableClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -77,11 +75,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -147,7 +147,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NullableClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 54793a3e9a88..57ccedfbc7ed 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NullableProperty(BaseModel): """ @@ -60,7 +58,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NullableProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -74,10 +72,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if name (nullable) is None @@ -88,7 +88,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NullableProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index 04d87e995252..5d5dd08b5e42 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NumberOnly(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 765586ddcd52..bb1f15415bfb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ObjectToTestAdditionalProperties(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ObjectToTestAdditionalProperties from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index c40a4e6de9ce..fdb0349a06de 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ObjectWithDeprecatedFields(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ObjectWithDeprecatedFields from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,10 +64,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of deprecated_ref @@ -78,7 +78,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ObjectWithDeprecatedFields from a dict""" if obj is None: return None @@ -89,7 +89,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "uuid": obj.get("uuid"), "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, + "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, "bars": obj.get("bars") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py index 0937e695ba8a..a0772dcbd50d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/one_of_enum_string.py @@ -34,7 +34,7 @@ class OneOfEnumString(BaseModel): # data type: EnumString2 oneof_schema_2_validator: Optional[EnumString2] = None actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"] + one_of_schemas: List[str] = Field(default=Literal["EnumString1", "EnumString2"]) model_config = { "validate_assignment": True, @@ -114,19 +114,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, EnumString1, EnumString2]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index 77ac9a9231d8..28b8c1e61ef2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -20,10 +20,8 @@ from datetime import datetime from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Order(BaseModel): """ @@ -64,7 +62,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Order from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -78,16 +76,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Order from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index eb722068e29e..8521d0ad3d6d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictBool, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class OuterComposite(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of OuterComposite from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of OuterComposite from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 7792ac502846..892f97eee19d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class OuterObjectWithEnumProperty(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of OuterObjectWithEnumProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,10 +63,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # set to None if str_value (nullable) is None @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of OuterObjectWithEnumProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 841425937741..3403a59ce248 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Parent(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Parent from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Parent from a dict""" if obj is None: return None @@ -90,7 +90,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj.get("optionalDict").items() + for _k, _v in obj["optionalDict"].items() ) if obj.get("optionalDict") is not None else None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index bb99cb9dc3ba..465a6865ade7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ParentWithOptionalDict(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ParentWithOptionalDict from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ParentWithOptionalDict from a dict""" if obj is None: return None @@ -90,7 +90,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj.get("optionalDict").items() + for _k, _v in obj["optionalDict"].items() ) if obj.get("optionalDict") is not None else None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index e03fa14d257b..b7fe4b531285 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -22,10 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.category import Category from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Pet(BaseModel): """ @@ -66,7 +64,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,10 +78,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of category @@ -99,7 +99,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Pet from a dict""" if obj is None: return None @@ -109,10 +109,10 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "id": obj.get("id"), - "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, + "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, "name": obj.get("name"), "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, + "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, "status": obj.get("status") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index d6a46cb9ed8b..ff3fc2d2af98 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -34,7 +34,7 @@ class Pig(BaseModel): # data type: DanishPig oneof_schema_2_validator: Optional[DanishPig] = None actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + one_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) model_config = { "validate_assignment": True, @@ -117,19 +117,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 75f8e2b37d99..41316803344f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -19,18 +19,16 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class PropertyNameCollision(BaseModel): """ PropertyNameCollision """ # noqa: E501 - type: Optional[StrictStr] = Field(default=None, alias="_type") + underscore_type: Optional[StrictStr] = Field(default=None, alias="_type") type: Optional[StrictStr] = None - type_: Optional[StrictStr] = None + type_with_underscore: Optional[StrictStr] = Field(default=None, alias="type_") __properties: ClassVar[List[str]] = ["_type", "type", "type_"] model_config = { @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of PropertyNameCollision from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,16 +62,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of PropertyNameCollision from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index 49ead9213158..2898439f1fca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ReadOnlyFirst(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ReadOnlyFirst from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,17 +62,19 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * OpenAPI `readOnly` fields are excluded. """ + excluded_fields: Set[str] = set([ + "bar", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "bar", - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ReadOnlyFirst from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index af988a86fc2d..a3bccde433b2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SecondRef(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SecondRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of circular_ref @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SecondRef from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None + "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index e11d1fb4ab90..5789d2a79c7f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SelfReferenceModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SelfReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SelfReferenceModel from a dict""" if obj is None: return None @@ -85,7 +85,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 46156ace0024..661d0b1792a8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SpecialModelName(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SpecialModelName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SpecialModelName from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index bfa50c24c616..ca09ee851acb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SpecialName(BaseModel): """ @@ -61,7 +59,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SpecialName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -75,10 +73,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of var_async @@ -87,7 +87,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SpecialName from a dict""" if obj is None: return None @@ -97,7 +97,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "property": obj.get("property"), - "async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None, + "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, "schema": obj.get("schema") }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index f4b1f4d65ad5..dfe1dd2a62fa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tag(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,16 +61,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tag from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index 5e2e6abdc1e2..f3af48ace469 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel400Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index 10549a0dd99e..4088a8f2835b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel404Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index 698976880975..0bcd4a918218 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 6c58d853c620..838868bc2044 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tiger(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tiger from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tiger from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 94a232efd670..068ac357b673 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -63,10 +61,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" if obj is None: return None @@ -96,7 +96,7 @@ def from_dict(cls, obj: Dict) -> Self: if _v is not None else None ) - for _k, _v in obj.get("dictProperty").items() + for _k, _v in obj.get("dictProperty", {}).items() ) }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index f8f0519a5024..3b03bb4e6b68 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -48,7 +46,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -62,16 +60,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 1607b7778d8c..d230bf1651ea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class User(BaseModel): """ @@ -55,7 +53,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of User from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -69,16 +67,18 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of User from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 18fa88ffc921..5fdbd2076dff 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class WithNestedOneOf(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of WithNestedOneOf from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,10 +64,12 @@ def to_dict(self) -> Dict[str, Any]: were set at model initialization. Other fields with value `None` are ignored. """ + excluded_fields: Set[str] = set([ + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested_pig @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of WithNestedOneOf from a dict""" if obj is None: return None @@ -91,8 +91,8 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None + "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, + "nested_oneof_enum_string": OneOfEnumString.from_dict(obj["nested_oneof_enum_string"]) if obj.get("nested_oneof_enum_string") is not None else None }) return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py index 0d4d999ee59d..0f09db5bcb99 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/rest.py @@ -16,6 +16,7 @@ import json import re import ssl +from typing import Optional import aiohttp import aiohttp_retry @@ -82,6 +83,7 @@ def __init__(self, configuration) -> None: ) retries = configuration.retries + self.retry_client: Optional[aiohttp_retry.RetryClient] if retries is not None: self.retry_client = aiohttp_retry.RetryClient( client_session=self.pool_manager, diff --git a/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml b/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml index 807b7380d910..8a61c2d138aa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml +++ b/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml @@ -25,6 +25,9 @@ typing-extensions = ">=4.7.1" pytest = ">=7.2.1" tox = ">=3.9.0" flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + [build-system] requires = ["setuptools"] @@ -32,3 +35,10 @@ build-backend = "setuptools.build_meta" [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "petstore_api", + #"test", # auto-generated tests + "tests", # hand-written tests +] diff --git a/samples/openapi3/client/petstore/python-aiohttp/test-requirements.txt b/samples/openapi3/client/petstore/python-aiohttp/test-requirements.txt index 3a0d0b939a1e..8e6d8cb13749 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/test-requirements.txt +++ b/samples/openapi3/client/petstore/python-aiohttp/test-requirements.txt @@ -1,3 +1,5 @@ pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_api_response.py deleted file mode 100644 index 54871268a190..000000000000 --- a/samples/openapi3/client/petstore/python-aiohttp/test/test_api_response.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding: utf-8 - -""" - OpenAPI Petstore - - This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 - - The version of the OpenAPI document: 1.0.0 - Generated by: https://openapi-generator.tech -""" - - -from __future__ import absolute_import - -import unittest -import datetime - -import petstore_api -from petstore_api.models.api_response import ApiResponse # noqa: E501 -from petstore_api.rest import ApiException - -class TestApiResponse(unittest.TestCase): - """ApiResponse unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional): - """Test ApiResponse - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # model = petstore_api.models.api_response.ApiResponse() # noqa: E501 - if include_optional : - return ApiResponse( - code = 56, - type = '', - message = '' - ) - else : - return ApiResponse( - ) - - def testApiResponse(self): - """Test ApiResponse""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_model_api_response.py new file mode 100644 index 000000000000..f37f34084401 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_model_api_response.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.model_api_response import ModelApiResponse + +class TestModelApiResponse(unittest.TestCase): + """ModelApiResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ModelApiResponse: + """Test ModelApiResponse + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ModelApiResponse` + """ + model = ModelApiResponse() + if include_optional: + return ModelApiResponse( + code = 56, + type = '', + message = '' + ) + else: + return ModelApiResponse( + ) + """ + + def testModelApiResponse(self): + """Test ModelApiResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 06be01a3bab9..090c6c431e53 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -12,7 +12,6 @@ docs/Animal.md docs/AnotherFakeApi.md docs/AnyOfColor.md docs/AnyOfPig.md -docs/ApiResponse.md docs/ArrayOfArrayOfModel.md docs/ArrayOfArrayOfNumberOnly.md docs/ArrayOfNumberOnly.md @@ -54,6 +53,7 @@ docs/MapOfArrayOfModel.md docs/MapTest.md docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/Model200Response.md +docs/ModelApiResponse.md docs/ModelReturn.md docs/Name.md docs/NullableClass.md @@ -116,7 +116,6 @@ petstore_api/models/all_of_with_single_ref.py petstore_api/models/animal.py petstore_api/models/any_of_color.py petstore_api/models/any_of_pig.py -petstore_api/models/api_response.py petstore_api/models/array_of_array_of_model.py petstore_api/models/array_of_array_of_number_only.py petstore_api/models/array_of_number_only.py @@ -155,6 +154,7 @@ petstore_api/models/map_of_array_of_model.py petstore_api/models/map_test.py petstore_api/models/mixed_properties_and_additional_properties_class.py petstore_api/models/model200_response.py +petstore_api/models/model_api_response.py petstore_api/models/model_return.py petstore_api/models/name.py petstore_api/models/nullable_class.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 49e0f07c8370..419d744d6ee9 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -146,7 +146,6 @@ Class | Method | HTTP request | Description - [Animal](docs/Animal.md) - [AnyOfColor](docs/AnyOfColor.md) - [AnyOfPig](docs/AnyOfPig.md) - - [ApiResponse](docs/ApiResponse.md) - [ArrayOfArrayOfModel](docs/ArrayOfArrayOfModel.md) - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) @@ -185,6 +184,7 @@ Class | Method | HTTP request | Description - [MapTest](docs/MapTest.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](docs/Model200Response.md) + - [ModelApiResponse](docs/ModelApiResponse.md) - [ModelReturn](docs/ModelReturn.md) - [Name](docs/Name.md) - [NullableClass](docs/NullableClass.md) diff --git a/samples/openapi3/client/petstore/python/docs/ApiResponse.md b/samples/openapi3/client/petstore/python/docs/ModelApiResponse.md similarity index 55% rename from samples/openapi3/client/petstore/python/docs/ApiResponse.md rename to samples/openapi3/client/petstore/python/docs/ModelApiResponse.md index 866258d527c8..659823b8051f 100644 --- a/samples/openapi3/client/petstore/python/docs/ApiResponse.md +++ b/samples/openapi3/client/petstore/python/docs/ModelApiResponse.md @@ -1,4 +1,4 @@ -# ApiResponse +# ModelApiResponse ## Properties @@ -12,19 +12,19 @@ Name | Type | Description | Notes ## Example ```python -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" -# create an instance of ApiResponse from a JSON string -api_response_instance = ApiResponse.from_json(json) +# create an instance of ModelApiResponse from a JSON string +model_api_response_instance = ModelApiResponse.from_json(json) # print the JSON string representation of the object -print ApiResponse.to_json() +print ModelApiResponse.to_json() # convert the object into a dict -api_response_dict = api_response_instance.to_dict() -# create an instance of ApiResponse from a dict -api_response_form_dict = api_response.from_dict(api_response_dict) +model_api_response_dict = model_api_response_instance.to_dict() +# create an instance of ModelApiResponse from a dict +model_api_response_form_dict = model_api_response.from_dict(model_api_response_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python/docs/PetApi.md b/samples/openapi3/client/petstore/python/docs/PetApi.md index b618dddb62c4..05c547865afd 100644 --- a/samples/openapi3/client/petstore/python/docs/PetApi.md +++ b/samples/openapi3/client/petstore/python/docs/PetApi.md @@ -803,7 +803,7 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file** -> ApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) +> ModelApiResponse upload_file(pet_id, additional_metadata=additional_metadata, file=file) uploads an image @@ -815,7 +815,7 @@ uploads an image ```python import petstore_api -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.rest import ApiException from pprint import pprint @@ -862,7 +862,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ModelApiResponse.md) ### Authorization @@ -882,7 +882,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **upload_file_with_required_file** -> ApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) +> ModelApiResponse upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) uploads an image (required) @@ -894,7 +894,7 @@ uploads an image (required) ```python import petstore_api -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.rest import ApiException from pprint import pprint @@ -941,7 +941,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**ModelApiResponse**](ModelApiResponse.md) ### Authorization diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index 72d39b9c55e6..f791bc531127 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -46,7 +46,6 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig -from petstore_api.models.api_response import ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly @@ -85,6 +84,7 @@ from petstore_api.models.map_test import MapTest from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.model_return import ModelReturn from petstore_api.models.name import Name from petstore_api.models.nullable_class import NullableClass diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index 6d3a726ace50..dbac022ff451 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index b6c6ae525d9c..acaad51e5b9c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from petstore_api.models.foo_get_default_response import FooGetDefaultResponse diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 00f591cb36cd..e14781d05a46 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from datetime import date, datetime from pydantic import Field, StrictBool, StrictBytes, StrictFloat, StrictInt, StrictStr, field_validator diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index e4136cae1765..ea004307ac1f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 695306c3e654..757b58c1b8ee 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -14,16 +14,12 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictBytes, StrictInt, StrictStr, field_validator from typing import List, Optional, Union from typing_extensions import Annotated -from petstore_api.models.api_response import ApiResponse +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.pet import Pet from petstore_api.api_client import ApiClient @@ -1976,7 +1972,7 @@ def upload_file( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse: + ) -> ModelApiResponse: """uploads an image @@ -2020,7 +2016,7 @@ def upload_file( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2051,7 +2047,7 @@ def upload_file_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ApiResponse]: + ) -> ApiResponse[ModelApiResponse]: """uploads an image @@ -2095,7 +2091,7 @@ def upload_file_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2170,7 +2166,7 @@ def upload_file_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2277,7 +2273,7 @@ def upload_file_with_required_file( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse: + ) -> ModelApiResponse: """uploads an image (required) @@ -2321,7 +2317,7 @@ def upload_file_with_required_file( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2352,7 +2348,7 @@ def upload_file_with_required_file_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ApiResponse]: + ) -> ApiResponse[ModelApiResponse]: """uploads an image (required) @@ -2396,7 +2392,7 @@ def upload_file_with_required_file_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2471,7 +2467,7 @@ def upload_file_with_required_file_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse", + '200': "ModelApiResponse", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index 4af3f6323fdf..09d850a80abf 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictStr from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index 72d1293f0cb9..a79d66d8ffe9 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -14,11 +14,7 @@ import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union - -try: - from typing import Annotated -except ImportError: - from typing_extensions import Annotated +from typing_extensions import Annotated from pydantic import Field, StrictStr from typing import List diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index 5e02dbf90a29..b3beec8cd356 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -272,15 +272,13 @@ def call_api( ) except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') raise e return response_data def response_deserialize( self, - response_data: rest.RESTResponse = None, + response_data: rest.RESTResponse, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -289,6 +287,8 @@ def response_deserialize( :return: ApiResponse """ + msg = "RESTResponse.read() must be called before passing it to response_deserialize()" + assert response_data.data is not None, msg response_type = response_types_map.get(str(response_data.status), None) if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_response.py b/samples/openapi3/client/petstore/python/petstore_api/api_response.py index 288b2e9a2543..9bc7c11f6b9f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_response.py @@ -1,8 +1,8 @@ """API response object.""" from __future__ import annotations -from typing import Dict, Optional, Generic, TypeVar -from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel +from typing import Optional, Generic, Mapping, TypeVar +from pydantic import Field, StrictInt, StrictBytes, BaseModel T = TypeVar("T") @@ -12,7 +12,7 @@ class ApiResponse(BaseModel, Generic[T]): """ status_code: StrictInt = Field(description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") + headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") data: T = Field(description="Deserialized data given the data type") raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") diff --git a/samples/openapi3/client/petstore/python/petstore_api/exceptions.py b/samples/openapi3/client/petstore/python/petstore_api/exceptions.py index 363d0d9f8744..0cb484becbdb 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/exceptions.py +++ b/samples/openapi3/client/petstore/python/petstore_api/exceptions.py @@ -12,7 +12,6 @@ """ # noqa: E501 from typing import Any, Optional - from typing_extensions import Self class OpenApiException(Exception): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index c106409daa97..945dd198de1a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -22,7 +22,6 @@ from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor from petstore_api.models.any_of_pig import AnyOfPig -from petstore_api.models.api_response import ApiResponse from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly from petstore_api.models.array_of_number_only import ArrayOfNumberOnly @@ -61,6 +60,7 @@ from petstore_api.models.map_test import MapTest from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass from petstore_api.models.model200_response import Model200Response +from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.model_return import ModelReturn from petstore_api.models.name import Name from petstore_api.models.nullable_class import NullableClass diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index ffa1d02e5ad7..10dfc6f2e5cc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesAnyType(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesAnyType from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesAnyType from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 62040a12d38e..559d50853186 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesClass(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index e0bb54ce6b2e..12b382a288ad 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesObject(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesObject from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index 3b9878cd05fb..7f2c44a9951b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index 00bdb6db0461..60e53f33aaed 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class AllOfWithSingleRef(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of AllOfWithSingleRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of AllOfWithSingleRef from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 3705b2ea7064..90a6fa86cf67 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Animal(BaseModel): """ @@ -41,7 +39,7 @@ class Animal(BaseModel): # JSON field name that stores the object type - __discriminator_property_name: ClassVar[List[str]] = 'className' + __discriminator_property_name: ClassVar[str] = 'className' # discriminator mappings __discriminator_value_class_map: ClassVar[Dict[str, str]] = { @@ -49,7 +47,7 @@ class Animal(BaseModel): } @classmethod - def get_discriminator_value(cls, obj: Dict) -> str: + def get_discriminator_value(cls, obj: Dict) -> Optional[str]: """Returns the discriminator value (object type) of the data""" discriminator_value = obj[cls.__discriminator_property_name] if discriminator_value: @@ -67,7 +65,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Union[Self, Self]: + def from_json(cls, json_str: str) -> Optional[Union[Self, Self]]: """Create an instance of Animal from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -82,11 +80,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -97,7 +97,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Union[Self, Self]: + def from_dict(cls, obj: Dict) -> Optional[Union[Self, Self]]: """Create an instance of Animal from a dict""" # look up the object type based on discriminator mapping object_type = cls.get_discriminator_value(obj) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index 18c98d1c1b84..f6252226ec20 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -22,6 +22,7 @@ from typing_extensions import Annotated from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] @@ -40,7 +41,7 @@ class AnyOfColor(BaseModel): actual_instance: Optional[Union[List[int], str]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Literal[ANYOFCOLOR_ANY_OF_SCHEMAS] + any_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) model_config = { "validate_assignment": True, @@ -133,22 +134,20 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, List[int], str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: - return "null" + return None - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - return json.dumps(self.actual_instance) + return self.actual_instance def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index afe139277b8a..6d730f25eb3b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -23,6 +23,7 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] @@ -39,7 +40,7 @@ class AnyOfPig(BaseModel): actual_instance: Optional[Union[BasquePig, DanishPig]] = None else: actual_instance: Any = None - any_of_schemas: List[str] = Literal[ANYOFPIG_ANY_OF_SCHEMAS] + any_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) model_config = { "validate_assignment": True, @@ -111,22 +112,20 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: - return "null" + return None - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - return json.dumps(self.actual_instance) + return self.actual_instance def to_str(self) -> str: """Returns the string representation of the actual instance""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 57e21deaa88a..fce06555166f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfArrayOfModel(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) @@ -89,7 +89,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfArrayOfModel from a dict""" if obj is None: return None @@ -100,7 +100,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "another_property": [ [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj.get("another_property") + for _item in obj["another_property"] ] if obj.get("another_property") is not None else None }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 6aa14d6b0c9a..603d18905645 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index 7c1eff55816c..1e72712f3114 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayOfNumberOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayOfNumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayOfNumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index a41c7db40456..0a95a9d89e45 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ArrayTest(BaseModel): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ArrayTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,11 +66,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) @@ -92,7 +92,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ArrayTest from a dict""" if obj is None: return None @@ -105,7 +105,7 @@ def from_dict(cls, obj: Dict) -> Self: "array_array_of_integer": obj.get("array_array_of_integer"), "array_array_of_model": [ [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj.get("array_array_of_model") + for _item in obj["array_array_of_model"] ] if obj.get("array_array_of_model") is not None else None }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index a2252acdb08c..7d8f9a47b70d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class BasquePig(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of BasquePig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of BasquePig from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index 368474763c5b..905771d5c006 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Capitalization(BaseModel): """ @@ -54,7 +52,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Capitalization from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -69,11 +67,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -84,7 +84,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Capitalization from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index f8a2abe2b162..18aecb1ed1dd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -20,10 +20,8 @@ from pydantic import StrictBool from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Cat(Animal): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Cat from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Cat from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index 611e76ac69db..b9dfc3639345 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Category(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Category from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Category from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index d4f772f39451..89fb15b0f61d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class CircularReferenceModel(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CircularReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of CircularReferenceModel from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested": FirstRef.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 25def7ccdc33..916b2e84030f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ClassModel(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ClassModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ClassModel from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index b56b1e5db45f..89cfd64b8081 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Client(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Client from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Client from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index 09ef62c0d945..0e55bb3ac7c7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -35,7 +35,7 @@ class Color(BaseModel): # data type: str oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: List[str] = Literal["List[int]", "str"] + one_of_schemas: List[str] = Field(default=Literal["List[int]", "str"]) model_config = { "validate_assignment": True, @@ -144,19 +144,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, List[int], str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index 4378deaf99af..6924884aa875 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List from petstore_api.models.creature_info import CreatureInfo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Creature(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Creature from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of info @@ -84,7 +84,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Creature from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None, + "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, "type": obj.get("type") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index 8b1aec3a9ae2..f2f67f9af7d5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class CreatureInfo(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of CreatureInfo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of CreatureInfo from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index 0f00519f93e3..fc6441b5c312 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DanishPig(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DanishPig from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DanishPig from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 74f788ee31a7..85bd3cb2ed1d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DeprecatedObject(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DeprecatedObject from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DeprecatedObject from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index b0947a28e002..6cddf02694ed 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -20,10 +20,8 @@ from pydantic import StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Dog(Animal): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Dog from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Dog from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 9a5b6ab93008..6c91ff08e9a4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class DummyModel(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of DummyModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of self_ref @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of DummyModel from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index f513c2afb7f9..58378df560d0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class EnumArrays(BaseModel): """ @@ -71,7 +69,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of EnumArrays from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -86,11 +84,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -101,7 +101,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of EnumArrays from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 74b8370d5329..62a470569886 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -23,10 +23,8 @@ from petstore_api.models.outer_enum_default_value import OuterEnumDefaultValue from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class EnumTest(BaseModel): """ @@ -108,7 +106,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of EnumTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -123,11 +121,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -143,7 +143,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of EnumTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index 6e468e461fc1..ee586b213270 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class File(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of File from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of File from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index 99ea21868b6d..5aff30bcf761 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FileSchemaTestClass(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FileSchemaTestClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of file @@ -91,7 +91,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FileSchemaTestClass from a dict""" if obj is None: return None @@ -100,8 +100,8 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "file": File.from_dict(obj.get("file")) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None + "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, + "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index 22efcd446c97..164c6e4a0d34 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FirstRef(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FirstRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of self_ref @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FirstRef from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj.get("self_ref")) if obj.get("self_ref") is not None else None + "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 8eaf65ef7381..89768b4152af 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Foo(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Foo from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Foo from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index 882912570dc5..6bf2f3c87517 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -20,10 +20,8 @@ from pydantic import BaseModel from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FooGetDefaultResponse(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FooGetDefaultResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of string @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FooGetDefaultResponse from a dict""" if obj is None: return None @@ -92,7 +92,7 @@ def from_dict(cls, obj: Dict) -> Self: return cls.model_validate(obj) _obj = cls.model_validate({ - "string": Foo.from_dict(obj.get("string")) if obj.get("string") is not None else None + "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 9e8aa92a329b..e5423c43ff68 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -22,10 +22,8 @@ from pydantic import BaseModel, Field, StrictBytes, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class FormatTest(BaseModel): """ @@ -108,7 +106,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of FormatTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -123,11 +121,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -138,7 +138,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of FormatTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index 50aace1dbeaa..2b896b571526 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class HasOnlyReadOnly(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of HasOnlyReadOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,13 +65,15 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "bar", + "foo", + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "bar", - "foo", - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -84,7 +84,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of HasOnlyReadOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index 386db83a29f6..1fda8def2df6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class HealthCheckResult(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of HealthCheckResult from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -84,7 +84,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of HealthCheckResult from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index ff301e4a7746..9b2742920bcd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class InnerDictWithProperty(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of InnerDictWithProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of InnerDictWithProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index b4309c791119..5153b87a311a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -33,7 +33,7 @@ class IntOrString(BaseModel): # data type: str oneof_schema_2_validator: Optional[StrictStr] = None actual_instance: Optional[Union[int, str]] = None - one_of_schemas: List[str] = Literal["int", "str"] + one_of_schemas: List[str] = Field(default=Literal["int", "str"]) model_config = { "validate_assignment": True, @@ -121,19 +121,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, int, str]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index 714f17b9f60f..50e7accd1178 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ListClass(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ListClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ListClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 9885de54a893..1cb86379a3a5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MapOfArrayOfModel(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MapOfArrayOfModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) @@ -89,7 +89,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MapOfArrayOfModel from a dict""" if obj is None: return None @@ -104,7 +104,7 @@ def from_dict(cls, obj: Dict) -> Self: if _v is not None else None ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap").items() + for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() ) }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 89d4c7d83454..2667fe45b8de 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MapTest(BaseModel): """ @@ -62,7 +60,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MapTest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -77,11 +75,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -92,7 +92,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MapTest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 6126316a91f9..9aa58fc21939 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -21,10 +21,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,11 +66,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in map (dict) @@ -90,7 +90,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" if obj is None: return None @@ -103,7 +103,7 @@ def from_dict(cls, obj: Dict) -> Self: "dateTime": obj.get("dateTime"), "map": dict( (_k, Animal.from_dict(_v)) - for _k, _v in obj.get("map").items() + for _k, _v in obj["map"].items() ) if obj.get("map") is not None else None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index dff34e31f317..41eceb717a72 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Model200Response(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Model200Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Model200Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py similarity index 84% rename from samples/openapi3/client/petstore/python/petstore_api/models/api_response.py rename to samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index 97cadc01d546..d15049825f5a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -19,14 +19,12 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self -class ApiResponse(BaseModel): +class ModelApiResponse(BaseModel): """ - ApiResponse + ModelApiResponse """ # noqa: E501 code: Optional[StrictInt] = None type: Optional[StrictStr] = None @@ -51,8 +49,8 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: - """Create an instance of ApiResponse from a JSON string""" + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ModelApiResponse from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -81,8 +81,8 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: - """Create an instance of ApiResponse from a dict""" + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: + """Create an instance of ModelApiResponse from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index 9f639fa1a3ea..a6084123439c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ModelReturn(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ModelReturn from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ModelReturn from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 1db30455de63..634f1b54ae03 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Name(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Name from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -69,13 +67,15 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "snake_case", + "var_123_number", + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "snake_case", - "var_123_number", - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -86,7 +86,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Name from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index 5c3c0e6597d3..61e58bd4d431 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -20,10 +20,8 @@ from datetime import date, datetime from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NullableClass(BaseModel): """ @@ -62,7 +60,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NullableClass from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -77,11 +75,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -147,7 +147,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NullableClass from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 3da13a5751fc..d2e02f4207c1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NullableProperty(BaseModel): """ @@ -61,7 +59,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NullableProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -76,11 +74,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -96,7 +96,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NullableProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index bbe39b678e33..451edc8035e6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class NumberOnly(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of NumberOnly from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of NumberOnly from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 4f7c9bbec666..8989aa318b88 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ObjectToTestAdditionalProperties(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ObjectToTestAdditionalProperties from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 7c03af763da6..05e4dc195d7d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictFloat, StrictStr from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ObjectWithDeprecatedFields(BaseModel): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ObjectWithDeprecatedFields from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,11 +66,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of deprecated_ref @@ -86,7 +86,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ObjectWithDeprecatedFields from a dict""" if obj is None: return None @@ -97,7 +97,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "uuid": obj.get("uuid"), "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj.get("deprecatedRef")) if obj.get("deprecatedRef") is not None else None, + "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, "bars": obj.get("bars") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index 0937e695ba8a..a0772dcbd50d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -34,7 +34,7 @@ class OneOfEnumString(BaseModel): # data type: EnumString2 oneof_schema_2_validator: Optional[EnumString2] = None actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: List[str] = Literal["EnumString1", "EnumString2"] + one_of_schemas: List[str] = Field(default=Literal["EnumString1", "EnumString2"]) model_config = { "validate_assignment": True, @@ -114,19 +114,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, EnumString1, EnumString2]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index 82682c94bb54..9690476d44c5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -20,10 +20,8 @@ from datetime import datetime from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Order(BaseModel): """ @@ -65,7 +63,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Order from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -80,11 +78,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -95,7 +95,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Order from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index 7862a53b3150..345e6177c33b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictBool, StrictFloat, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class OuterComposite(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of OuterComposite from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of OuterComposite from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index 2294c351852b..9d6614d8b7f3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class OuterObjectWithEnumProperty(BaseModel): """ @@ -52,7 +50,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of OuterObjectWithEnumProperty from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -67,11 +65,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -87,7 +87,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of OuterObjectWithEnumProperty from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 53c13813a546..7cc33541408b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Parent(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Parent from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) @@ -87,7 +87,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Parent from a dict""" if obj is None: return None @@ -98,7 +98,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj.get("optionalDict").items() + for _k, _v in obj["optionalDict"].items() ) if obj.get("optionalDict") is not None else None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 5f5ca1b49d80..c06ee6c241d2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ParentWithOptionalDict(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ParentWithOptionalDict from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) @@ -87,7 +87,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ParentWithOptionalDict from a dict""" if obj is None: return None @@ -98,7 +98,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "optionalDict": dict( (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj.get("optionalDict").items() + for _k, _v in obj["optionalDict"].items() ) if obj.get("optionalDict") is not None else None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 164ca8d6d30b..aabfb267b236 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -22,10 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.category import Category from petstore_api.models.tag import Tag -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Pet(BaseModel): """ @@ -67,7 +65,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Pet from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -82,11 +80,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of category @@ -107,7 +107,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Pet from a dict""" if obj is None: return None @@ -117,10 +117,10 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "id": obj.get("id"), - "category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None, + "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, "name": obj.get("name"), "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, + "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, "status": obj.get("status") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 4918fd685348..a347d69f50c0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -34,7 +34,7 @@ class Pig(BaseModel): # data type: DanishPig oneof_schema_2_validator: Optional[DanishPig] = None actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: List[str] = Literal["BasquePig", "DanishPig"] + one_of_schemas: List[str] = Field(default=Literal["BasquePig", "DanishPig"]) model_config = { "validate_assignment": True, @@ -132,19 +132,17 @@ def to_json(self) -> str: if self.actual_instance is None: return "null" - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): return self.actual_instance.to_json() else: return json.dumps(self.actual_instance) - def to_dict(self) -> Dict: + def to_dict(self) -> Optional[Union[Dict, BasquePig, DanishPig]]: """Returns the dict representation of the actual instance""" if self.actual_instance is None: return None - to_dict = getattr(self.actual_instance, "to_dict", None) - if callable(to_dict): + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: # primitive type diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index f46aabd06b66..d3cd3f5da220 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class PropertyNameCollision(BaseModel): """ @@ -51,7 +49,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of PropertyNameCollision from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,11 +64,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of PropertyNameCollision from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index 01648d4b72f5..599aefafe79e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class ReadOnlyFirst(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of ReadOnlyFirst from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -66,12 +64,14 @@ def to_dict(self) -> Dict[str, Any]: * OpenAPI `readOnly` fields are excluded. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "bar", + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "bar", - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of ReadOnlyFirst from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 212ac8e17091..b2630f172251 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SecondRef(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SecondRef from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of circular_ref @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SecondRef from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj.get("circular_ref")) if obj.get("circular_ref") is not None else None + "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 3e4c11e183a3..fb0e4fa49894 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SelfReferenceModel(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SelfReferenceModel from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested @@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SelfReferenceModel from a dict""" if obj is None: return None @@ -93,7 +93,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested": DummyModel.from_dict(obj.get("nested")) if obj.get("nested") is not None else None + "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index ae89384c05f7..5b33405cdaec 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SpecialModelName(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SpecialModelName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SpecialModelName from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 76ddb42ad22e..4f46ebbb8735 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class SpecialName(BaseModel): """ @@ -62,7 +60,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of SpecialName from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -77,11 +75,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of var_async @@ -95,7 +95,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of SpecialName from a dict""" if obj is None: return None @@ -105,7 +105,7 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "property": obj.get("property"), - "async": Category.from_dict(obj.get("async")) if obj.get("async") is not None else None, + "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, "schema": obj.get("schema") }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index 6af90ba1f409..cc61c274b838 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tag(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tag from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tag from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index 83f78d2c72d9..7bf345588f30 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel400Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index f8f3cb0ed429..0624512ca780 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestErrorResponsesWithModel404Response from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index 698976880975..0bcd4a918218 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index d9cfc98ad51a..18d182e11dd5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class Tiger(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of Tiger from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of Tiger from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index cfb0a080ec7c..4442a496799a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -20,10 +20,8 @@ from pydantic import BaseModel, Field from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -50,7 +48,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -65,11 +63,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) @@ -89,7 +89,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" if obj is None: return None @@ -104,7 +104,7 @@ def from_dict(cls, obj: Dict) -> Self: if _v is not None else None ) - for _k, _v in obj.get("dictProperty").items() + for _k, _v in obj.get("dictProperty", {}).items() ) }) # store additional fields in additional_properties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 63379e11eb55..5cfd62b04065 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -49,7 +47,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -64,11 +62,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index 13b2422bba78..6d71a60dc539 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -19,10 +19,8 @@ from pydantic import BaseModel, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class User(BaseModel): """ @@ -56,7 +54,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of User from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -71,11 +69,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # puts key-value pairs in additional_properties in the top level @@ -86,7 +86,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of User from a dict""" if obj is None: return None diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index cce8a4460d08..acedc9b78507 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -21,10 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig -try: - from typing import Self -except ImportError: - from typing_extensions import Self +from typing import Optional, Set +from typing_extensions import Self class WithNestedOneOf(BaseModel): """ @@ -53,7 +51,7 @@ def to_json(self) -> str: return json.dumps(self.to_dict()) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Optional[Self]: """Create an instance of WithNestedOneOf from a JSON string""" return cls.from_dict(json.loads(json_str)) @@ -68,11 +66,13 @@ def to_dict(self) -> Dict[str, Any]: are ignored. * Fields in `self.additional_properties` are added to the output dict. """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + _dict = self.model_dump( by_alias=True, - exclude={ - "additional_properties", - }, + exclude=excluded_fields, exclude_none=True, ) # override the default output from pydantic by calling `to_dict()` of nested_pig @@ -89,7 +89,7 @@ def to_dict(self) -> Dict[str, Any]: return _dict @classmethod - def from_dict(cls, obj: Dict) -> Self: + def from_dict(cls, obj: Optional[Dict]) -> Optional[Self]: """Create an instance of WithNestedOneOf from a dict""" if obj is None: return None @@ -99,8 +99,8 @@ def from_dict(cls, obj: Dict) -> Self: _obj = cls.model_validate({ "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj.get("nested_pig")) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": OneOfEnumString.from_dict(obj.get("nested_oneof_enum_string")) if obj.get("nested_oneof_enum_string") is not None else None + "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, + "nested_oneof_enum_string": OneOfEnumString.from_dict(obj["nested_oneof_enum_string"]) if obj.get("nested_oneof_enum_string") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/samples/openapi3/client/petstore/python/petstore_api/rest.py b/samples/openapi3/client/petstore/python/petstore_api/rest.py index ff75022d695c..b53900b945b3 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/rest.py +++ b/samples/openapi3/client/petstore/python/petstore_api/rest.py @@ -71,56 +71,45 @@ def __init__(self, configuration) -> None: else: cert_reqs = ssl.CERT_NONE - addition_pool_args = {} + pool_args = { + "cert_reqs": cert_reqs, + "ca_certs": configuration.ssl_ca_cert, + "cert_file": configuration.cert_file, + "key_file": configuration.key_file, + } if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = ( + pool_args['assert_hostname'] = ( configuration.assert_hostname ) if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + pool_args['retries'] = configuration.retries if configuration.tls_server_name: - addition_pool_args['server_hostname'] = configuration.tls_server_name + pool_args['server_hostname'] = configuration.tls_server_name if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options + pool_args['socket_options'] = configuration.socket_options if configuration.connection_pool_maxsize is not None: - addition_pool_args['maxsize'] = configuration.connection_pool_maxsize + pool_args['maxsize'] = configuration.connection_pool_maxsize # https pool manager + self.pool_manager: urllib3.PoolManager + if configuration.proxy: if is_socks_proxy_url(configuration.proxy): from urllib3.contrib.socks import SOCKSProxyManager - self.pool_manager = SOCKSProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["headers"] = configuration.proxy_headers + self.pool_manager = SOCKSProxyManager(**pool_args) else: - self.pool_manager = urllib3.ProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) + pool_args["proxy_url"] = configuration.proxy + pool_args["proxy_headers"] = configuration.proxy_headers + self.pool_manager = urllib3.ProxyManager(**pool_args) else: - self.pool_manager = urllib3.PoolManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) + self.pool_manager = urllib3.PoolManager(**pool_args) def request( self, diff --git a/samples/openapi3/client/petstore/python/poetry.lock b/samples/openapi3/client/petstore/python/poetry.lock new file mode 100644 index 000000000000..2e5a00ee1120 --- /dev/null +++ b/samples/openapi3/client/petstore/python/poetry.lock @@ -0,0 +1,671 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + +[[package]] +name = "annotated-types" +version = "0.5.0" +description = "Reusable constraint types to use with typing.Annotated" +optional = false +python-versions = ">=3.7" +files = [ + {file = "annotated_types-0.5.0-py3-none-any.whl", hash = "sha256:58da39888f92c276ad970249761ebea80ba544b77acddaa1a4d6cf78287d45fd"}, + {file = "annotated_types-0.5.0.tar.gz", hash = "sha256:47cdc3490d9ac1506ce92c7aaa76c579dc3509ff11e098fc867e5130ab7be802"}, +] + +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "distlib" +version = "0.3.8" +description = "Distribution utilities" +optional = false +python-versions = "*" +files = [ + {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, + {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.0" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, + {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "filelock" +version = "3.12.2" +description = "A platform independent file lock." +optional = false +python-versions = ">=3.7" +files = [ + {file = "filelock-3.12.2-py3-none-any.whl", hash = "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec"}, + {file = "filelock-3.12.2.tar.gz", hash = "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81"}, +] + +[package.extras] +docs = ["furo (>=2023.5.20)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)"] + +[[package]] +name = "flake8" +version = "5.0.4" +description = "the modular source code checker: pep8 pyflakes and co" +optional = false +python-versions = ">=3.6.1" +files = [ + {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, + {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=1.1.0,<4.3", markers = "python_version < \"3.8\""} +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.9.0,<2.10.0" +pyflakes = ">=2.5.0,<2.6.0" + +[[package]] +name = "importlib-metadata" +version = "4.2.0" +description = "Read metadata from Python packages" +optional = false +python-versions = ">=3.6" +files = [ + {file = "importlib_metadata-4.2.0-py3-none-any.whl", hash = "sha256:057e92c15bc8d9e8109738a48db0ccb31b4d9d5cfbee5a8670879a30be66304b"}, + {file = "importlib_metadata-4.2.0.tar.gz", hash = "sha256:b7e52a1f8dec14a75ea73e0891f3060099ca1d8e6a462a4dff11c3e119ea1b31"}, +] + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", "pyfakefs", "pytest (>=4.6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-flake8", "pytest-mypy"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + +[[package]] +name = "mypy" +version = "1.4.1" +description = "Optional static typing for Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mypy-1.4.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:566e72b0cd6598503e48ea610e0052d1b8168e60a46e0bfd34b3acf2d57f96a8"}, + {file = "mypy-1.4.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca637024ca67ab24a7fd6f65d280572c3794665eaf5edcc7e90a866544076878"}, + {file = "mypy-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0dde1d180cd84f0624c5dcaaa89c89775550a675aff96b5848de78fb11adabcd"}, + {file = "mypy-1.4.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:8c4d8e89aa7de683e2056a581ce63c46a0c41e31bd2b6d34144e2c80f5ea53dc"}, + {file = "mypy-1.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:bfdca17c36ae01a21274a3c387a63aa1aafe72bff976522886869ef131b937f1"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7549fbf655e5825d787bbc9ecf6028731973f78088fbca3a1f4145c39ef09462"}, + {file = "mypy-1.4.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:98324ec3ecf12296e6422939e54763faedbfcc502ea4a4c38502082711867258"}, + {file = "mypy-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:141dedfdbfe8a04142881ff30ce6e6653c9685b354876b12e4fe6c78598b45e2"}, + {file = "mypy-1.4.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8207b7105829eca6f3d774f64a904190bb2231de91b8b186d21ffd98005f14a7"}, + {file = "mypy-1.4.1-cp311-cp311-win_amd64.whl", hash = "sha256:16f0db5b641ba159eff72cff08edc3875f2b62b2fa2bc24f68c1e7a4e8232d01"}, + {file = "mypy-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:470c969bb3f9a9efcedbadcd19a74ffb34a25f8e6b0e02dae7c0e71f8372f97b"}, + {file = "mypy-1.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e5952d2d18b79f7dc25e62e014fe5a23eb1a3d2bc66318df8988a01b1a037c5b"}, + {file = "mypy-1.4.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:190b6bab0302cec4e9e6767d3eb66085aef2a1cc98fe04936d8a42ed2ba77bb7"}, + {file = "mypy-1.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9d40652cc4fe33871ad3338581dca3297ff5f2213d0df345bcfbde5162abf0c9"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:01fd2e9f85622d981fd9063bfaef1aed6e336eaacca00892cd2d82801ab7c042"}, + {file = "mypy-1.4.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2460a58faeea905aeb1b9b36f5065f2dc9a9c6e4c992a6499a2360c6c74ceca3"}, + {file = "mypy-1.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2746d69a8196698146a3dbe29104f9eb6a2a4d8a27878d92169a6c0b74435b6"}, + {file = "mypy-1.4.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ae704dcfaa180ff7c4cfbad23e74321a2b774f92ca77fd94ce1049175a21c97f"}, + {file = "mypy-1.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:43d24f6437925ce50139a310a64b2ab048cb2d3694c84c71c3f2a1626d8101dc"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c482e1246726616088532b5e964e39765b6d1520791348e6c9dc3af25b233828"}, + {file = "mypy-1.4.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:43b592511672017f5b1a483527fd2684347fdffc041c9ef53428c8dc530f79a3"}, + {file = "mypy-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:34a9239d5b3502c17f07fd7c0b2ae6b7dd7d7f6af35fbb5072c6208e76295816"}, + {file = "mypy-1.4.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5703097c4936bbb9e9bce41478c8d08edd2865e177dc4c52be759f81ee4dd26c"}, + {file = "mypy-1.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:e02d700ec8d9b1859790c0475df4e4092c7bf3272a4fd2c9f33d87fac4427b8f"}, + {file = "mypy-1.4.1-py3-none-any.whl", hash = "sha256:45d32cec14e7b97af848bddd97d85ea4f0db4d5a149ed9676caa4eb2f7402bb4"}, + {file = "mypy-1.4.1.tar.gz", hash = "sha256:9bbcd9ab8ea1f2e1c8031c21445b511442cc45c89951e49bbf852cbb70755b1b"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} +typing-extensions = ">=4.1.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +python2 = ["typed-ast (>=1.4.0,<2)"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + +[[package]] +name = "packaging" +version = "23.2" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] + +[[package]] +name = "pem" +version = "21.2.0" +description = "Easy PEM file parsing in Python." +optional = false +python-versions = "*" +files = [ + {file = "pem-21.2.0-py2.py3-none-any.whl", hash = "sha256:64afb669f05502c071d0706ee66e51471718ae248ba39624919da7b4ea73506e"}, + {file = "pem-21.2.0.tar.gz", hash = "sha256:c491833b092662626fd58a87375d450637d4ee94996ad9bbbd42593428e93e5a"}, +] + +[package.extras] +dev = ["certifi", "coverage[toml] (>=5.0.2)", "furo", "pre-commit", "pretend", "pyopenssl", "pytest", "sphinx", "twisted[tls]"] +docs = ["furo", "sphinx"] +tests = ["certifi", "coverage[toml] (>=5.0.2)", "pretend", "pyopenssl", "pytest"] + +[[package]] +name = "platformdirs" +version = "2.6.2" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +optional = false +python-versions = ">=3.7" +files = [ + {file = "platformdirs-2.6.2-py3-none-any.whl", hash = "sha256:83c8f6d04389165de7c9b6f0c682439697887bca0aa2f1c87ef1826be3584490"}, + {file = "platformdirs-2.6.2.tar.gz", hash = "sha256:e1fea1fe471b9ff8332e229df3cb7de4f53eeea4998d3b6bfff542115e998bd2"}, +] + +[package.dependencies] +typing-extensions = {version = ">=4.4", markers = "python_version < \"3.8\""} + +[package.extras] +docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=5.3)", "sphinx-autodoc-typehints (>=1.19.5)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] + +[[package]] +name = "pluggy" +version = "1.2.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pluggy-1.2.0-py3-none-any.whl", hash = "sha256:c2fd55a7d7a3863cba1a013e4e2414658b1d07b6bc57b3919e0c63c9abb99849"}, + {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "py" +version = "1.11.0" +description = "library with cross-python path, ini-parsing, io, code, log facilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, +] + +[[package]] +name = "pycodestyle" +version = "2.9.1" +description = "Python style guide checker" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, + {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, +] + +[[package]] +name = "pycryptodome" +version = "3.19.1" +description = "Cryptographic library for Python" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "pycryptodome-3.19.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:694020d2ff985cd714381b9da949a21028c24b86f562526186f6af7c7547e986"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:4464b0e8fd5508bff9baf18e6fd4c6548b1ac2ce9862d6965ff6a84ec9cb302a"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:420972f9c62978e852c74055d81c354079ce3c3a2213a92c9d7e37bbc63a26e2"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1bc0c49d986a1491d66d2a56570f12e960b12508b7e71f2423f532e28857f36"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-musllinux_1_1_aarch64.whl", hash = "sha256:e038ab77fec0956d7aa989a3c647652937fc142ef41c9382c2ebd13c127d5b4a"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-win32.whl", hash = "sha256:a991f8ffe8dfe708f86690948ae46442eebdd0fff07dc1b605987939a34ec979"}, + {file = "pycryptodome-3.19.1-cp27-cp27m-win_amd64.whl", hash = "sha256:2c16426ef49d9cba018be2340ea986837e1dfa25c2ea181787971654dd49aadd"}, + {file = "pycryptodome-3.19.1-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:6d0d2b97758ebf2f36c39060520447c26455acb3bcff309c28b1c816173a6ff5"}, + {file = "pycryptodome-3.19.1-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:b8b80ff92049fd042177282917d994d344365ab7e8ec2bc03e853d93d2401786"}, + {file = "pycryptodome-3.19.1-cp27-cp27mu-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd4e7e8bf0fc1ada854688b9b309ee607e2aa85a8b44180f91021a4dd330a928"}, + {file = "pycryptodome-3.19.1-cp27-cp27mu-musllinux_1_1_aarch64.whl", hash = "sha256:8cf5d3d6cf921fa81acd1f632f6cedcc03f5f68fc50c364cd39490ba01d17c49"}, + {file = "pycryptodome-3.19.1-cp35-abi3-macosx_10_9_universal2.whl", hash = "sha256:67939a3adbe637281c611596e44500ff309d547e932c449337649921b17b6297"}, + {file = "pycryptodome-3.19.1-cp35-abi3-macosx_10_9_x86_64.whl", hash = "sha256:11ddf6c9b52116b62223b6a9f4741bc4f62bb265392a4463282f7f34bb287180"}, + {file = "pycryptodome-3.19.1-cp35-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3e6f89480616781d2a7f981472d0cdb09b9da9e8196f43c1234eff45c915766"}, + {file = "pycryptodome-3.19.1-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27e1efcb68993b7ce5d1d047a46a601d41281bba9f1971e6be4aa27c69ab8065"}, + {file = "pycryptodome-3.19.1-cp35-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c6273ca5a03b672e504995529b8bae56da0ebb691d8ef141c4aa68f60765700"}, + {file = "pycryptodome-3.19.1-cp35-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:b0bfe61506795877ff974f994397f0c862d037f6f1c0bfc3572195fc00833b96"}, + {file = "pycryptodome-3.19.1-cp35-abi3-musllinux_1_1_i686.whl", hash = "sha256:f34976c5c8eb79e14c7d970fb097482835be8d410a4220f86260695ede4c3e17"}, + {file = "pycryptodome-3.19.1-cp35-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:7c9e222d0976f68d0cf6409cfea896676ddc1d98485d601e9508f90f60e2b0a2"}, + {file = "pycryptodome-3.19.1-cp35-abi3-win32.whl", hash = "sha256:4805e053571140cb37cf153b5c72cd324bb1e3e837cbe590a19f69b6cf85fd03"}, + {file = "pycryptodome-3.19.1-cp35-abi3-win_amd64.whl", hash = "sha256:a470237ee71a1efd63f9becebc0ad84b88ec28e6784a2047684b693f458f41b7"}, + {file = "pycryptodome-3.19.1-pp27-pypy_73-manylinux2010_x86_64.whl", hash = "sha256:ed932eb6c2b1c4391e166e1a562c9d2f020bfff44a0e1b108f67af38b390ea89"}, + {file = "pycryptodome-3.19.1-pp27-pypy_73-win32.whl", hash = "sha256:81e9d23c0316fc1b45d984a44881b220062336bbdc340aa9218e8d0656587934"}, + {file = "pycryptodome-3.19.1-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:37e531bf896b70fe302f003d3be5a0a8697737a8d177967da7e23eff60d6483c"}, + {file = "pycryptodome-3.19.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cd4e95b0eb4b28251c825fe7aa941fe077f993e5ca9b855665935b86fbb1cc08"}, + {file = "pycryptodome-3.19.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c22c80246c3c880c6950d2a8addf156cee74ec0dc5757d01e8e7067a3c7da015"}, + {file = "pycryptodome-3.19.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:e70f5c839c7798743a948efa2a65d1fe96bb397fe6d7f2bde93d869fe4f0ad69"}, + {file = "pycryptodome-3.19.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:6c3df3613592ea6afaec900fd7189d23c8c28b75b550254f4bd33fe94acb84b9"}, + {file = "pycryptodome-3.19.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:08b445799d571041765e7d5c9ca09c5d3866c2f22eeb0dd4394a4169285184f4"}, + {file = "pycryptodome-3.19.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:954d156cd50130afd53f8d77f830fe6d5801bd23e97a69d358fed068f433fbfe"}, + {file = "pycryptodome-3.19.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:b7efd46b0b4ac869046e814d83244aeab14ef787f4850644119b1c8b0ec2d637"}, + {file = "pycryptodome-3.19.1.tar.gz", hash = "sha256:8ae0dd1bcfada451c35f9e29a3e5db385caabc190f98e4a80ad02a61098fb776"}, +] + +[[package]] +name = "pydantic" +version = "2.5.3" +description = "Data validation using Python type hints" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydantic-2.5.3-py3-none-any.whl", hash = "sha256:d0caf5954bee831b6bfe7e338c32b9e30c85dfe080c843680783ac2b631673b4"}, + {file = "pydantic-2.5.3.tar.gz", hash = "sha256:b3ef57c62535b0941697cce638c08900d87fcb67e29cfa99e8a68f747f393f7a"}, +] + +[package.dependencies] +annotated-types = ">=0.4.0" +importlib-metadata = {version = "*", markers = "python_version == \"3.7\""} +pydantic-core = "2.14.6" +typing-extensions = ">=4.6.1" + +[package.extras] +email = ["email-validator (>=2.0.0)"] + +[[package]] +name = "pydantic-core" +version = "2.14.6" +description = "" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydantic_core-2.14.6-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:72f9a942d739f09cd42fffe5dc759928217649f070056f03c70df14f5770acf9"}, + {file = "pydantic_core-2.14.6-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6a31d98c0d69776c2576dda4b77b8e0c69ad08e8b539c25c7d0ca0dc19a50d6c"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5aa90562bc079c6c290f0512b21768967f9968e4cfea84ea4ff5af5d917016e4"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:370ffecb5316ed23b667d99ce4debe53ea664b99cc37bfa2af47bc769056d534"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f85f3843bdb1fe80e8c206fe6eed7a1caeae897e496542cee499c374a85c6e08"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9862bf828112e19685b76ca499b379338fd4c5c269d897e218b2ae8fcb80139d"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:036137b5ad0cb0004c75b579445a1efccd072387a36c7f217bb8efd1afbe5245"}, + {file = "pydantic_core-2.14.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:92879bce89f91f4b2416eba4429c7b5ca22c45ef4a499c39f0c5c69257522c7c"}, + {file = "pydantic_core-2.14.6-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:0c08de15d50fa190d577e8591f0329a643eeaed696d7771760295998aca6bc66"}, + {file = "pydantic_core-2.14.6-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:36099c69f6b14fc2c49d7996cbf4f87ec4f0e66d1c74aa05228583225a07b590"}, + {file = "pydantic_core-2.14.6-cp310-none-win32.whl", hash = "sha256:7be719e4d2ae6c314f72844ba9d69e38dff342bc360379f7c8537c48e23034b7"}, + {file = "pydantic_core-2.14.6-cp310-none-win_amd64.whl", hash = "sha256:36fa402dcdc8ea7f1b0ddcf0df4254cc6b2e08f8cd80e7010d4c4ae6e86b2a87"}, + {file = "pydantic_core-2.14.6-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:dea7fcd62915fb150cdc373212141a30037e11b761fbced340e9db3379b892d4"}, + {file = "pydantic_core-2.14.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ffff855100bc066ff2cd3aa4a60bc9534661816b110f0243e59503ec2df38421"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b027c86c66b8627eb90e57aee1f526df77dc6d8b354ec498be9a757d513b92b"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:00b1087dabcee0b0ffd104f9f53d7d3eaddfaa314cdd6726143af6bc713aa27e"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:75ec284328b60a4e91010c1acade0c30584f28a1f345bc8f72fe8b9e46ec6a96"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e1f4744eea1501404b20b0ac059ff7e3f96a97d3e3f48ce27a139e053bb370b"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b2602177668f89b38b9f84b7b3435d0a72511ddef45dc14446811759b82235a1"}, + {file = "pydantic_core-2.14.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6c8edaea3089bf908dd27da8f5d9e395c5b4dc092dbcce9b65e7156099b4b937"}, + {file = "pydantic_core-2.14.6-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:478e9e7b360dfec451daafe286998d4a1eeaecf6d69c427b834ae771cad4b622"}, + {file = "pydantic_core-2.14.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:b6ca36c12a5120bad343eef193cc0122928c5c7466121da7c20f41160ba00ba2"}, + {file = "pydantic_core-2.14.6-cp311-none-win32.whl", hash = "sha256:2b8719037e570639e6b665a4050add43134d80b687288ba3ade18b22bbb29dd2"}, + {file = "pydantic_core-2.14.6-cp311-none-win_amd64.whl", hash = "sha256:78ee52ecc088c61cce32b2d30a826f929e1708f7b9247dc3b921aec367dc1b23"}, + {file = "pydantic_core-2.14.6-cp311-none-win_arm64.whl", hash = "sha256:a19b794f8fe6569472ff77602437ec4430f9b2b9ec7a1105cfd2232f9ba355e6"}, + {file = "pydantic_core-2.14.6-cp312-cp312-macosx_10_7_x86_64.whl", hash = "sha256:667aa2eac9cd0700af1ddb38b7b1ef246d8cf94c85637cbb03d7757ca4c3fdec"}, + {file = "pydantic_core-2.14.6-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cdee837710ef6b56ebd20245b83799fce40b265b3b406e51e8ccc5b85b9099b7"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c5bcf3414367e29f83fd66f7de64509a8fd2368b1edf4351e862910727d3e51"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:26a92ae76f75d1915806b77cf459811e772d8f71fd1e4339c99750f0e7f6324f"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a983cca5ed1dd9a35e9e42ebf9f278d344603bfcb174ff99a5815f953925140a"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cb92f9061657287eded380d7dc455bbf115430b3aa4741bdc662d02977e7d0af"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e4ace1e220b078c8e48e82c081e35002038657e4b37d403ce940fa679e57113b"}, + {file = "pydantic_core-2.14.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ef633add81832f4b56d3b4c9408b43d530dfca29e68fb1b797dcb861a2c734cd"}, + {file = "pydantic_core-2.14.6-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7e90d6cc4aad2cc1f5e16ed56e46cebf4877c62403a311af20459c15da76fd91"}, + {file = "pydantic_core-2.14.6-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:e8a5ac97ea521d7bde7621d86c30e86b798cdecd985723c4ed737a2aa9e77d0c"}, + {file = "pydantic_core-2.14.6-cp312-none-win32.whl", hash = "sha256:f27207e8ca3e5e021e2402ba942e5b4c629718e665c81b8b306f3c8b1ddbb786"}, + {file = "pydantic_core-2.14.6-cp312-none-win_amd64.whl", hash = "sha256:b3e5fe4538001bb82e2295b8d2a39356a84694c97cb73a566dc36328b9f83b40"}, + {file = "pydantic_core-2.14.6-cp312-none-win_arm64.whl", hash = "sha256:64634ccf9d671c6be242a664a33c4acf12882670b09b3f163cd00a24cffbd74e"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-macosx_10_7_x86_64.whl", hash = "sha256:24368e31be2c88bd69340fbfe741b405302993242ccb476c5c3ff48aeee1afe0"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:e33b0834f1cf779aa839975f9d8755a7c2420510c0fa1e9fa0497de77cd35d2c"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6af4b3f52cc65f8a0bc8b1cd9676f8c21ef3e9132f21fed250f6958bd7223bed"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d15687d7d7f40333bd8266f3814c591c2e2cd263fa2116e314f60d82086e353a"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:095b707bb287bfd534044166ab767bec70a9bba3175dcdc3371782175c14e43c"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94fc0e6621e07d1e91c44e016cc0b189b48db053061cc22d6298a611de8071bb"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1ce830e480f6774608dedfd4a90c42aac4a7af0a711f1b52f807130c2e434c06"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a306cdd2ad3a7d795d8e617a58c3a2ed0f76c8496fb7621b6cd514eb1532cae8"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:2f5fa187bde8524b1e37ba894db13aadd64faa884657473b03a019f625cee9a8"}, + {file = "pydantic_core-2.14.6-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:438027a975cc213a47c5d70672e0d29776082155cfae540c4e225716586be75e"}, + {file = "pydantic_core-2.14.6-cp37-none-win32.whl", hash = "sha256:f96ae96a060a8072ceff4cfde89d261837b4294a4f28b84a28765470d502ccc6"}, + {file = "pydantic_core-2.14.6-cp37-none-win_amd64.whl", hash = "sha256:e646c0e282e960345314f42f2cea5e0b5f56938c093541ea6dbf11aec2862391"}, + {file = "pydantic_core-2.14.6-cp38-cp38-macosx_10_7_x86_64.whl", hash = "sha256:db453f2da3f59a348f514cfbfeb042393b68720787bbef2b4c6068ea362c8149"}, + {file = "pydantic_core-2.14.6-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3860c62057acd95cc84044e758e47b18dcd8871a328ebc8ccdefd18b0d26a21b"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:36026d8f99c58d7044413e1b819a67ca0e0b8ebe0f25e775e6c3d1fabb3c38fb"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8ed1af8692bd8d2a29d702f1a2e6065416d76897d726e45a1775b1444f5928a7"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:314ccc4264ce7d854941231cf71b592e30d8d368a71e50197c905874feacc8a8"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:982487f8931067a32e72d40ab6b47b1628a9c5d344be7f1a4e668fb462d2da42"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2dbe357bc4ddda078f79d2a36fc1dd0494a7f2fad83a0a684465b6f24b46fe80"}, + {file = "pydantic_core-2.14.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2f6ffc6701a0eb28648c845f4945a194dc7ab3c651f535b81793251e1185ac3d"}, + {file = "pydantic_core-2.14.6-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:7f5025db12fc6de7bc1104d826d5aee1d172f9ba6ca936bf6474c2148ac336c1"}, + {file = "pydantic_core-2.14.6-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:dab03ed811ed1c71d700ed08bde8431cf429bbe59e423394f0f4055f1ca0ea60"}, + {file = "pydantic_core-2.14.6-cp38-none-win32.whl", hash = "sha256:dfcbebdb3c4b6f739a91769aea5ed615023f3c88cb70df812849aef634c25fbe"}, + {file = "pydantic_core-2.14.6-cp38-none-win_amd64.whl", hash = "sha256:99b14dbea2fdb563d8b5a57c9badfcd72083f6006caf8e126b491519c7d64ca8"}, + {file = "pydantic_core-2.14.6-cp39-cp39-macosx_10_7_x86_64.whl", hash = "sha256:4ce8299b481bcb68e5c82002b96e411796b844d72b3e92a3fbedfe8e19813eab"}, + {file = "pydantic_core-2.14.6-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b9a9d92f10772d2a181b5ca339dee066ab7d1c9a34ae2421b2a52556e719756f"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fd9e98b408384989ea4ab60206b8e100d8687da18b5c813c11e92fd8212a98e0"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4f86f1f318e56f5cbb282fe61eb84767aee743ebe32c7c0834690ebea50c0a6b"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86ce5fcfc3accf3a07a729779d0b86c5d0309a4764c897d86c11089be61da160"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3dcf1978be02153c6a31692d4fbcc2a3f1db9da36039ead23173bc256ee3b91b"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eedf97be7bc3dbc8addcef4142f4b4164066df0c6f36397ae4aaed3eb187d8ab"}, + {file = "pydantic_core-2.14.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d5f916acf8afbcab6bacbb376ba7dc61f845367901ecd5e328fc4d4aef2fcab0"}, + {file = "pydantic_core-2.14.6-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:8a14c192c1d724c3acbfb3f10a958c55a2638391319ce8078cb36c02283959b9"}, + {file = "pydantic_core-2.14.6-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:0348b1dc6b76041516e8a854ff95b21c55f5a411c3297d2ca52f5528e49d8411"}, + {file = "pydantic_core-2.14.6-cp39-none-win32.whl", hash = "sha256:de2a0645a923ba57c5527497daf8ec5df69c6eadf869e9cd46e86349146e5975"}, + {file = "pydantic_core-2.14.6-cp39-none-win_amd64.whl", hash = "sha256:aca48506a9c20f68ee61c87f2008f81f8ee99f8d7f0104bff3c47e2d148f89d9"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:d5c28525c19f5bb1e09511669bb57353d22b94cf8b65f3a8d141c389a55dec95"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:78d0768ee59baa3de0f4adac9e3748b4b1fffc52143caebddfd5ea2961595277"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b93785eadaef932e4fe9c6e12ba67beb1b3f1e5495631419c784ab87e975670"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a874f21f87c485310944b2b2734cd6d318765bcbb7515eead33af9641816506e"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b89f4477d915ea43b4ceea6756f63f0288941b6443a2b28c69004fe07fde0d0d"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:172de779e2a153d36ee690dbc49c6db568d7b33b18dc56b69a7514aecbcf380d"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:dfcebb950aa7e667ec226a442722134539e77c575f6cfaa423f24371bb8d2e94"}, + {file = "pydantic_core-2.14.6-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:55a23dcd98c858c0db44fc5c04fc7ed81c4b4d33c653a7c45ddaebf6563a2f66"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-macosx_10_7_x86_64.whl", hash = "sha256:4241204e4b36ab5ae466ecec5c4c16527a054c69f99bba20f6f75232a6a534e2"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e574de99d735b3fc8364cba9912c2bec2da78775eba95cbb225ef7dda6acea24"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1302a54f87b5cd8528e4d6d1bf2133b6aa7c6122ff8e9dc5220fbc1e07bffebd"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f8e81e4b55930e5ffab4a68db1af431629cf2e4066dbdbfef65348b8ab804ea8"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c99462ffc538717b3e60151dfaf91125f637e801f5ab008f81c402f1dff0cd0f"}, + {file = "pydantic_core-2.14.6-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e4cf2d5829f6963a5483ec01578ee76d329eb5caf330ecd05b3edd697e7d768a"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:cf10b7d58ae4a1f07fccbf4a0a956d705356fea05fb4c70608bb6fa81d103cda"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:399ac0891c284fa8eb998bcfa323f2234858f5d2efca3950ae58c8f88830f145"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c6a5c79b28003543db3ba67d1df336f253a87d3112dac3a51b94f7d48e4c0e1"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:599c87d79cab2a6a2a9df4aefe0455e61e7d2aeede2f8577c1b7c0aec643ee8e"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e166ad47ba900f2542a80d83f9fc65fe99eb63ceec4debec160ae729824052"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:3a0b5db001b98e1c649dd55afa928e75aa4087e587b9524a4992316fa23c9fba"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:747265448cb57a9f37572a488a57d873fd96bf51e5bb7edb52cfb37124516da4"}, + {file = "pydantic_core-2.14.6-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:7ebe3416785f65c28f4f9441e916bfc8a54179c8dea73c23023f7086fa601c5d"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:86c963186ca5e50d5c8287b1d1c9d3f8f024cbe343d048c5bd282aec2d8641f2"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:e0641b506486f0b4cd1500a2a65740243e8670a2549bb02bc4556a83af84ae03"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:71d72ca5eaaa8d38c8df16b7deb1a2da4f650c41b58bb142f3fb75d5ad4a611f"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:27e524624eace5c59af499cd97dc18bb201dc6a7a2da24bfc66ef151c69a5f2a"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a3dde6cac75e0b0902778978d3b1646ca9f438654395a362cb21d9ad34b24acf"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:00646784f6cd993b1e1c0e7b0fdcbccc375d539db95555477771c27555e3c556"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:23598acb8ccaa3d1d875ef3b35cb6376535095e9405d91a3d57a8c7db5d29341"}, + {file = "pydantic_core-2.14.6-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:7f41533d7e3cf9520065f610b41ac1c76bc2161415955fbcead4981b22c7611e"}, + {file = "pydantic_core-2.14.6.tar.gz", hash = "sha256:1fd0c1d395372843fba13a51c28e3bb9d59bd7aebfeb17358ffaaa1e4dbbe948"}, +] + +[package.dependencies] +typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" + +[[package]] +name = "pyflakes" +version = "2.5.0" +description = "passive checker of Python programs" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, + {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, +] + +[[package]] +name = "pytest" +version = "7.4.4" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, + {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, +] + +[package.dependencies] +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[package.dependencies] +six = ">=1.5" + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "tox" +version = "3.28.0" +description = "tox is a generic virtualenv management and test command line tool" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" +files = [ + {file = "tox-3.28.0-py2.py3-none-any.whl", hash = "sha256:57b5ab7e8bb3074edc3c0c0b4b192a4f3799d3723b2c5b76f1fa9f2d40316eea"}, + {file = "tox-3.28.0.tar.gz", hash = "sha256:d0d28f3fe6d6d7195c27f8b054c3e99d5451952b54abdae673b71609a581f640"}, +] + +[package.dependencies] +colorama = {version = ">=0.4.1", markers = "platform_system == \"Windows\""} +filelock = ">=3.0.0" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +packaging = ">=14" +pluggy = ">=0.12.0" +py = ">=1.4.17" +six = ">=1.14.0" +tomli = {version = ">=2.0.1", markers = "python_version >= \"3.7\" and python_version < \"3.11\""} +virtualenv = ">=16.0.0,<20.0.0 || >20.0.0,<20.0.1 || >20.0.1,<20.0.2 || >20.0.2,<20.0.3 || >20.0.3,<20.0.4 || >20.0.4,<20.0.5 || >20.0.5,<20.0.6 || >20.0.6,<20.0.7 || >20.0.7" + +[package.extras] +docs = ["pygments-github-lexers (>=0.0.5)", "sphinx (>=2.0.0)", "sphinxcontrib-autoprogram (>=0.1.5)", "towncrier (>=18.5.0)"] +testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pathlib2 (>=2.3.3)", "psutil (>=5.6.1)", "pytest (>=4.0.0)", "pytest-cov (>=2.5.1)", "pytest-mock (>=1.10.0)", "pytest-randomly (>=1.0.0)"] + +[[package]] +name = "typed-ast" +version = "1.5.5" +description = "a fork of Python 2 and 3 ast modules with type comment support" +optional = false +python-versions = ">=3.6" +files = [ + {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"}, + {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"}, + {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"}, + {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"}, + {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"}, + {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"}, + {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"}, + {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"}, + {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"}, + {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"}, + {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"}, + {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"}, + {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"}, + {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"}, + {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"}, + {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"}, + {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"}, + {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"}, + {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"}, + {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"}, + {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"}, + {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"}, + {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"}, + {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"}, + {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"}, + {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"}, +] + +[[package]] +name = "types-python-dateutil" +version = "2.8.19.14" +description = "Typing stubs for python-dateutil" +optional = false +python-versions = "*" +files = [ + {file = "types-python-dateutil-2.8.19.14.tar.gz", hash = "sha256:1f4f10ac98bb8b16ade9dbee3518d9ace017821d94b057a425b069f834737f4b"}, + {file = "types_python_dateutil-2.8.19.14-py3-none-any.whl", hash = "sha256:f977b8de27787639986b4e28963263fd0e5158942b3ecef91b9335c130cb1ce9"}, +] + +[[package]] +name = "typing-extensions" +version = "4.7.1" +description = "Backported and Experimental Type Hints for Python 3.7+" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.7.1-py3-none-any.whl", hash = "sha256:440d5dd3af93b060174bf433bccd69b0babc3b15b1a8dca43789fd7f61514b36"}, + {file = "typing_extensions-4.7.1.tar.gz", hash = "sha256:b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2"}, +] + +[[package]] +name = "urllib3" +version = "2.0.7" +description = "HTTP library with thread-safe connection pooling, file post, and more." +optional = false +python-versions = ">=3.7" +files = [ + {file = "urllib3-2.0.7-py3-none-any.whl", hash = "sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e"}, + {file = "urllib3-2.0.7.tar.gz", hash = "sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84"}, +] + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] +secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.1.0)", "urllib3-secure-extra"] +socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] +zstd = ["zstandard (>=0.18.0)"] + +[[package]] +name = "virtualenv" +version = "20.16.2" +description = "Virtual Python Environment builder" +optional = false +python-versions = ">=3.6" +files = [ + {file = "virtualenv-20.16.2-py2.py3-none-any.whl", hash = "sha256:635b272a8e2f77cb051946f46c60a54ace3cb5e25568228bd6b57fc70eca9ff3"}, + {file = "virtualenv-20.16.2.tar.gz", hash = "sha256:0ef5be6d07181946891f5abc8047fda8bc2f0b4b9bf222c64e6e8963baee76db"}, +] + +[package.dependencies] +distlib = ">=0.3.1,<1" +filelock = ">=3.2,<4" +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +platformdirs = ">=2,<3" + +[package.extras] +docs = ["proselint (>=0.10.2)", "sphinx (>=3)", "sphinx-argparse (>=0.2.5)", "sphinx-rtd-theme (>=0.4.3)", "towncrier (>=21.3)"] +testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", "packaging (>=20.0)", "pytest (>=4)", "pytest-env (>=0.6.2)", "pytest-freezegun (>=0.4.1)", "pytest-mock (>=2)", "pytest-randomly (>=1)", "pytest-timeout (>=1)"] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "96d25a1701fc4c71e041dd068430d11b575227644b810a999176e8f98aa070e4" diff --git a/samples/openapi3/client/petstore/python/pyproject.toml b/samples/openapi3/client/petstore/python/pyproject.toml index 0d153fcb0c3d..bb84812899bd 100644 --- a/samples/openapi3/client/petstore/python/pyproject.toml +++ b/samples/openapi3/client/petstore/python/pyproject.toml @@ -23,6 +23,9 @@ typing-extensions = ">=4.7.1" pytest = ">=7.2.1" tox = ">=3.9.0" flake8 = ">=4.0.0" +types-python-dateutil = ">=2.8.19.14" +mypy = "1.4.1" + [build-system] requires = ["setuptools"] @@ -30,3 +33,10 @@ build-backend = "setuptools.build_meta" [tool.pylint.'MESSAGES CONTROL'] extension-pkg-whitelist = "pydantic" + +[tool.mypy] +files = [ + "petstore_api", + #"test", # auto-generated tests + "tests", # hand-written tests +] diff --git a/samples/openapi3/client/petstore/python/test-requirements.txt b/samples/openapi3/client/petstore/python/test-requirements.txt index 3a0d0b939a1e..8e6d8cb13749 100755 --- a/samples/openapi3/client/petstore/python/test-requirements.txt +++ b/samples/openapi3/client/petstore/python/test-requirements.txt @@ -1,3 +1,5 @@ pytest~=7.1.3 pytest-cov>=2.8.1 pytest-randomly>=3.12.0 +mypy>=1.4.1 +types-python-dateutil>=2.8.19 diff --git a/samples/openapi3/client/petstore/python/test/test_api_response.py b/samples/openapi3/client/petstore/python/test/test_api_response.py deleted file mode 100644 index 95efd33bce57..000000000000 --- a/samples/openapi3/client/petstore/python/test/test_api_response.py +++ /dev/null @@ -1,53 +0,0 @@ -# coding: utf-8 - -""" - OpenAPI Petstore - - This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 - - The version of the OpenAPI document: 1.0.0 - Generated by: https://openapi-generator.tech -""" - - -from __future__ import absolute_import - -import unittest -import datetime - -import petstore_api -from petstore_api.models.api_response import ApiResponse # noqa: E501 -from petstore_api.rest import ApiException - -class TestApiResponse(unittest.TestCase): - """ApiResponse unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional): - """Test ApiResponse - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # model = petstore_api.models.api_response.ApiResponse() # noqa: E501 - if include_optional : - return ApiResponse( - code = 56, - type = '', - message = '' - ) - else : - return ApiResponse( - ) - - def testApiResponse(self): - """Test ApiResponse""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_model_api_response.py b/samples/openapi3/client/petstore/python/test/test_model_api_response.py new file mode 100644 index 000000000000..f37f34084401 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_model_api_response.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.model_api_response import ModelApiResponse + +class TestModelApiResponse(unittest.TestCase): + """ModelApiResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ModelApiResponse: + """Test ModelApiResponse + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ModelApiResponse` + """ + model = ModelApiResponse() + if include_optional: + return ModelApiResponse( + code = 56, + type = '', + message = '' + ) + else: + return ModelApiResponse( + ) + """ + + def testModelApiResponse(self): + """Test ModelApiResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index b06eeaa0831f..7de872a26714 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -459,7 +459,7 @@ def test_additional_properties(self): self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) pet_ap.additional_properties["something-new"] = "haha" - self.assertEqual(pet_ap.to_json(), '{"id":1,"name":"test name","photoUrls":["string"],"status":"available","something-new":"haha"}') + self.assertEqual(pet_ap.to_json(), '{"id": 1, "name": "test name", "photoUrls": ["string"], "status": "available", "something-new": "haha"}') self.assertEqual(type(pet_ap2.additional_properties), dict) self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) self.assertEqual(pet_ap.additional_properties["something-new"], "haha") @@ -589,6 +589,8 @@ def test_allof(self): # shouldn't throw NameError self.assertEqual(model.to_json(), '{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + +class TestdditionalPropertiesAnyType(unittest.TestCase): def test_additional_properties(self): a1 = petstore_api.AdditionalPropertiesAnyType() a1.additional_properties = { "abc": 123 }