diff --git a/.changeset/drop_support_for_python_38.md b/.changeset/drop_support_for_python_38.md new file mode 100644 index 000000000..ed9060c5c --- /dev/null +++ b/.changeset/drop_support_for_python_38.md @@ -0,0 +1,8 @@ +--- +default: major +--- + +# Drop support for Python 3.8 + +Python 3.8 is no longer supported. "New" 3.9 syntax, like generics on builtin collections, is used both in the generator +and the generated code. diff --git a/.changeset/type_is_now_a_reserved_field_name.md b/.changeset/type_is_now_a_reserved_field_name.md new file mode 100644 index 000000000..f804f0f51 --- /dev/null +++ b/.changeset/type_is_now_a_reserved_field_name.md @@ -0,0 +1,8 @@ +--- +default: major +--- + +# `type` is now a reserved field name + +Because `type` is used in type annotations now, it is no longer a valid field name. Fields which were previously named +`type` will be renamed to `type_`. diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 34543fdf2..055ecd17f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -11,7 +11,7 @@ jobs: test: strategy: matrix: - python: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] + python: [ "3.9", "3.10", "3.11", "3.12", "3.13" ] os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} steps: @@ -131,7 +131,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5.3.0 with: - python-version: "3.8" + python-version: "3.9" - name: Get Python Version id: get_python_version run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 52b67100a..194f26dcc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ To request a feature: ### Setting up a Dev Environment 1. Make sure you have [PDM](https://pdm-project.org) installed and up to date. -2. Make sure you have a supported Python version (e.g. 3.8) installed. +2. Make sure you have a supported Python version (e.g. 3.13) installed. 3. Use `pdm install` in the project directory to create a virtual environment with the relevant dependencies. ### Writing tests diff --git a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py index 79a699a1e..69973bee2 100644 --- a/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py +++ b/end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py @@ -1,7 +1,5 @@ """Contains methods for accessing the API""" -from typing import Type - from .bodies import BodiesEndpoints from .config import ConfigEndpoints from .default import DefaultEndpoints @@ -19,53 +17,53 @@ class MyTestApiClientApi: @classmethod - def bodies(cls) -> Type[BodiesEndpoints]: + def bodies(cls) -> type[BodiesEndpoints]: return BodiesEndpoints @classmethod - def tests(cls) -> Type[TestsEndpoints]: + def tests(cls) -> type[TestsEndpoints]: return TestsEndpoints @classmethod - def defaults(cls) -> Type[DefaultsEndpoints]: + def defaults(cls) -> type[DefaultsEndpoints]: return DefaultsEndpoints @classmethod - def enums(cls) -> Type[EnumsEndpoints]: + def enums(cls) -> type[EnumsEndpoints]: return EnumsEndpoints @classmethod - def responses(cls) -> Type[ResponsesEndpoints]: + def responses(cls) -> type[ResponsesEndpoints]: return ResponsesEndpoints @classmethod - def default(cls) -> Type[DefaultEndpoints]: + def default(cls) -> type[DefaultEndpoints]: return DefaultEndpoints @classmethod - def parameters(cls) -> Type[ParametersEndpoints]: + def parameters(cls) -> type[ParametersEndpoints]: return ParametersEndpoints @classmethod - def tag1(cls) -> Type[Tag1Endpoints]: + def tag1(cls) -> type[Tag1Endpoints]: return Tag1Endpoints @classmethod - def location(cls) -> Type[LocationEndpoints]: + def location(cls) -> type[LocationEndpoints]: return LocationEndpoints @classmethod - def true_(cls) -> Type[True_Endpoints]: + def true_(cls) -> type[True_Endpoints]: return True_Endpoints @classmethod - def naming(cls) -> Type[NamingEndpoints]: + def naming(cls) -> type[NamingEndpoints]: return NamingEndpoints @classmethod - def parameter_references(cls) -> Type[ParameterReferencesEndpoints]: + def parameter_references(cls) -> type[ParameterReferencesEndpoints]: return ParameterReferencesEndpoints @classmethod - def config(cls) -> Type[ConfigEndpoints]: + def config(cls) -> type[ConfigEndpoints]: return ConfigEndpoints diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py index 646279c98..626bacfa6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/json_like.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: JsonLikeBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/bodies/json-like", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py index 136cd3b5b..84ec8eee0 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/post_bodies_multiple.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -19,10 +19,10 @@ def _get_kwargs( PostBodiesMultipleDataBody, PostBodiesMultipleFilesBody, ], -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/bodies/multiple", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py index 20eb25160..a79cf178a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/bodies/refs.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: AModel, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/bodies/refs", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py index 29d4ed7c3..2bd74aac4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/config/content_type_override.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -11,10 +11,10 @@ def _get_kwargs( *, body: str, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/config/content-type-override", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py index 7bf48a0f8..7de222f55 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,14 +11,14 @@ def _get_kwargs( *, common: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["common"] = common params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/common_parameters", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py index 1d2fa73a8..9d837acd6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -9,8 +9,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/models/allof", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py index 85be98c28..85f68fb7c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -14,8 +14,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/models/oneof-with-required-const", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py index 8fc836ad3..5bd941c69 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,14 +11,14 @@ def _get_kwargs( *, common: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["common"] = common params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/common_parameters", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py index ec2f3fc3c..fe7adf04c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,8 +12,8 @@ def _get_kwargs( *, client_query: str, url_query: str, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["client"] = client_query @@ -21,7 +21,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/naming/reserved-parameters", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py index 12ac54947..ffc9b535e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py @@ -1,6 +1,6 @@ import datetime from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx from dateutil.parser import isoparse @@ -22,14 +22,14 @@ def _get_kwargs( float_with_int: float = 3.0, int_prop: int = 7, boolean_prop: bool = False, - list_prop: List[AnEnum], + list_prop: list[AnEnum], union_prop: Union[float, str] = "not a float", union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, enum_prop: AnEnum, model_prop: "ModelWithUnionProperty", required_model_prop: "ModelWithUnionProperty", -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["string_prop"] = string_prop @@ -77,7 +77,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/defaults", "params": params, @@ -123,7 +123,7 @@ def sync_detailed( float_with_int: float = 3.0, int_prop: int = 7, boolean_prop: bool = False, - list_prop: List[AnEnum], + list_prop: list[AnEnum], union_prop: Union[float, str] = "not a float", union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, enum_prop: AnEnum, @@ -140,7 +140,7 @@ def sync_detailed( float_with_int (float): Default: 3.0. int_prop (int): Default: 7. boolean_prop (bool): Default: False. - list_prop (List[AnEnum]): + list_prop (list[AnEnum]): union_prop (Union[float, str]): Default: 'not a float'. union_prop_with_ref (Union[AnEnum, Unset, float]): Default: 0.6. enum_prop (AnEnum): For testing Enums in all the ways they can be used @@ -188,7 +188,7 @@ def sync( float_with_int: float = 3.0, int_prop: int = 7, boolean_prop: bool = False, - list_prop: List[AnEnum], + list_prop: list[AnEnum], union_prop: Union[float, str] = "not a float", union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, enum_prop: AnEnum, @@ -205,7 +205,7 @@ def sync( float_with_int (float): Default: 3.0. int_prop (int): Default: 7. boolean_prop (bool): Default: False. - list_prop (List[AnEnum]): + list_prop (list[AnEnum]): union_prop (Union[float, str]): Default: 'not a float'. union_prop_with_ref (Union[AnEnum, Unset, float]): Default: 0.6. enum_prop (AnEnum): For testing Enums in all the ways they can be used @@ -248,7 +248,7 @@ async def asyncio_detailed( float_with_int: float = 3.0, int_prop: int = 7, boolean_prop: bool = False, - list_prop: List[AnEnum], + list_prop: list[AnEnum], union_prop: Union[float, str] = "not a float", union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, enum_prop: AnEnum, @@ -265,7 +265,7 @@ async def asyncio_detailed( float_with_int (float): Default: 3.0. int_prop (int): Default: 7. boolean_prop (bool): Default: False. - list_prop (List[AnEnum]): + list_prop (list[AnEnum]): union_prop (Union[float, str]): Default: 'not a float'. union_prop_with_ref (Union[AnEnum, Unset, float]): Default: 0.6. enum_prop (AnEnum): For testing Enums in all the ways they can be used @@ -311,7 +311,7 @@ async def asyncio( float_with_int: float = 3.0, int_prop: int = 7, boolean_prop: bool = False, - list_prop: List[AnEnum], + list_prop: list[AnEnum], union_prop: Union[float, str] = "not a float", union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6, enum_prop: AnEnum, @@ -328,7 +328,7 @@ async def asyncio( float_with_int (float): Default: 3.0. int_prop (int): Default: 7. boolean_prop (bool): Default: False. - list_prop (List[AnEnum]): + list_prop (list[AnEnum]): union_prop (Union[float, str]): Default: 'not a float'. union_prop_with_ref (Union[AnEnum, Unset, float]): Default: 0.6. enum_prop (AnEnum): For testing Enums in all the ways they can be used diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 851cdf385..52385855c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,14 +11,14 @@ def _get_kwargs( *, bool_enum: bool, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["bool_enum"] = bool_enum params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/enum/bool", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py index f7c403771..26c3729fe 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,15 +12,15 @@ def _get_kwargs( *, int_enum: AnIntEnum, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} json_int_enum = int_enum.value params["int_enum"] = json_int_enum params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/enum/int", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py index 140bb3780..ad9428a72 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_header_types.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -18,8 +18,8 @@ def _get_kwargs( integer_header: Union[Unset, int] = UNSET, int_enum_header: Union[Unset, GetLocationHeaderTypesIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetLocationHeaderTypesStringEnumHeader] = UNSET, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} if not isinstance(boolean_header, Unset): headers["Boolean-Header"] = "true" if boolean_header else "false" @@ -38,7 +38,7 @@ def _get_kwargs( if not isinstance(string_enum_header, Unset): headers["String-Enum-Header"] = str(string_enum_header) - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/location/header/types", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py index fcbc8213a..e28e37a36 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py @@ -1,6 +1,6 @@ import datetime from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -15,8 +15,8 @@ def _get_kwargs( null_required: Union[None, datetime.datetime], null_not_required: Union[None, Unset, datetime.datetime] = UNSET, not_null_not_required: Union[Unset, datetime.datetime] = UNSET, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} json_not_null_required = not_null_required.isoformat() params["not_null_required"] = json_not_null_required @@ -44,7 +44,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/location/query/optionality", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py index a94062b1b..a0caba2d6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/hyphen_in_path.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -10,8 +10,8 @@ def _get_kwargs( hyphen_in_path: str, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/naming/{hyphen_in_path}", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py index ece16e492..7df2d318f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/mixed_case.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,8 +13,8 @@ def _get_kwargs( *, mixed_case: str, mixedCase: str, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["mixed_case"] = mixed_case @@ -22,7 +22,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/naming/mixed-case", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py index 083bdd12d..3bb8b698b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/naming/post_naming_property_conflict_with_import.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -15,10 +15,10 @@ def _get_kwargs( *, body: PostNamingPropertyConflictWithImportBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/naming/property-conflict-with-import", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py index 3d8c6ad36..e7a8e2712 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -15,8 +15,8 @@ def _get_kwargs( integer_param: Union[Unset, int] = 0, header_param: Union[None, Unset, str] = UNSET, cookie_param: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} if not isinstance(header_param, Unset): headers["header param"] = header_param @@ -24,7 +24,7 @@ def _get_kwargs( if cookie_param is not UNSET: cookies["cookie param"] = cookie_param - params: Dict[str, Any] = {} + params: dict[str, Any] = {} params["string param"] = string_param @@ -32,7 +32,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": f"/parameter-references/{path_param}", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py index b842b8834..704996107 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,14 +12,14 @@ def _get_kwargs( param_path: str, *, param_query: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["param"] = param_query params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "delete", "url": f"/common_parameters_overriding/{param_path}", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py index 5dc4aa7ec..b6efbba9b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,14 +12,14 @@ def _get_kwargs( param_path: str, *, param_query: str = "overridden_in_GET", -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["param"] = param_query params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": f"/common_parameters_overriding/{param_path}", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py index 834875ff7..6a7ed7fd5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -14,8 +14,8 @@ def _get_kwargs( param_query: Union[Unset, str] = UNSET, param_header: Union[Unset, str] = UNSET, param_cookie: Union[Unset, str] = UNSET, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} if not isinstance(param_header, Unset): headers["param"] = param_header @@ -23,13 +23,13 @@ def _get_kwargs( if param_cookie is not UNSET: cookies["param"] = param_cookie - params: Dict[str, Any] = {} + params: dict[str, Any] = {} params["param"] = param_query params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": f"/same-name-multiple-locations/{param_path}", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py index 22f476963..44345aa26 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,8 +13,8 @@ def _get_kwargs( param2: int, param1: str, param3: int, -) -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": f"/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py index 97bc5922a..cf0599306 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/post_responses_unions_simple_before_complex.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,8 +11,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "post", "url": "/responses/unions/simple_before_complex", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py index cc4dd9531..057ceb2de 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/responses/text_response.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "post", "url": "/responses/text", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py index c6756b522..62631355f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tag_with_number", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py index 30ed5aa7f..0852815d2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/callback_test.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: AModel, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/callback", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py index 4cfc8e5a5..e7cd44f70 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/description_with_backslash.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/description-with-backslash", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py index 53cb6598d..147eed3a7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/basic_lists/booleans", } @@ -17,9 +17,9 @@ def _get_kwargs() -> Dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[bool]]: +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[bool]]: if response.status_code == 200: - response_200 = cast(List[bool], response.json()) + response_200 = cast(list[bool], response.json()) return response_200 if client.raise_on_unexpected_status: @@ -28,7 +28,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[List[bool]]: +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[bool]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[bool]]: +) -> Response[list[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -50,7 +50,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[bool]] + Response[list[bool]] """ kwargs = _get_kwargs() @@ -65,7 +65,7 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[bool]]: +) -> Optional[list[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -75,7 +75,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[bool] + list[bool] """ return sync_detailed( @@ -86,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[bool]]: +) -> Response[list[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -96,7 +96,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[bool]] + Response[list[bool]] """ kwargs = _get_kwargs() @@ -109,7 +109,7 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[bool]]: +) -> Optional[list[bool]]: """Get Basic List Of Booleans Get a list of booleans @@ -119,7 +119,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[bool] + list[bool] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py index 7d1f71559..02b3abb1f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/basic_lists/floats", } @@ -17,9 +17,9 @@ def _get_kwargs() -> Dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[float]]: +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[float]]: if response.status_code == 200: - response_200 = cast(List[float], response.json()) + response_200 = cast(list[float], response.json()) return response_200 if client.raise_on_unexpected_status: @@ -28,7 +28,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[List[float]]: +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[float]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[float]]: +) -> Response[list[float]]: """Get Basic List Of Floats Get a list of floats @@ -50,7 +50,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[float]] + Response[list[float]] """ kwargs = _get_kwargs() @@ -65,7 +65,7 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[float]]: +) -> Optional[list[float]]: """Get Basic List Of Floats Get a list of floats @@ -75,7 +75,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[float] + list[float] """ return sync_detailed( @@ -86,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[float]]: +) -> Response[list[float]]: """Get Basic List Of Floats Get a list of floats @@ -96,7 +96,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[float]] + Response[list[float]] """ kwargs = _get_kwargs() @@ -109,7 +109,7 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[float]]: +) -> Optional[list[float]]: """Get Basic List Of Floats Get a list of floats @@ -119,7 +119,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[float] + list[float] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py index 14d978288..e71537363 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_integers.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/basic_lists/integers", } @@ -17,9 +17,9 @@ def _get_kwargs() -> Dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[int]]: +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[int]]: if response.status_code == 200: - response_200 = cast(List[int], response.json()) + response_200 = cast(list[int], response.json()) return response_200 if client.raise_on_unexpected_status: @@ -28,7 +28,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[List[int]]: +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[int]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[int]]: +) -> Response[list[int]]: """Get Basic List Of Integers Get a list of integers @@ -50,7 +50,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[int]] + Response[list[int]] """ kwargs = _get_kwargs() @@ -65,7 +65,7 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[int]]: +) -> Optional[list[int]]: """Get Basic List Of Integers Get a list of integers @@ -75,7 +75,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[int] + list[int] """ return sync_detailed( @@ -86,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[int]]: +) -> Response[list[int]]: """Get Basic List Of Integers Get a list of integers @@ -96,7 +96,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[int]] + Response[list[int]] """ kwargs = _get_kwargs() @@ -109,7 +109,7 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[int]]: +) -> Optional[list[int]]: """Get Basic List Of Integers Get a list of integers @@ -119,7 +119,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[int] + list[int] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py index 61b2bc3f5..70f153829 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_strings.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/basic_lists/strings", } @@ -17,9 +17,9 @@ def _get_kwargs() -> Dict[str, Any]: return _kwargs -def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[List[str]]: +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[list[str]]: if response.status_code == 200: - response_200 = cast(List[str], response.json()) + response_200 = cast(list[str], response.json()) return response_200 if client.raise_on_unexpected_status: @@ -28,7 +28,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt return None -def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[List[str]]: +def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[list[str]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -40,7 +40,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt def sync_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[str]]: +) -> Response[list[str]]: """Get Basic List Of Strings Get a list of strings @@ -50,7 +50,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[str]] + Response[list[str]] """ kwargs = _get_kwargs() @@ -65,7 +65,7 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[str]]: +) -> Optional[list[str]]: """Get Basic List Of Strings Get a list of strings @@ -75,7 +75,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[str] + list[str] """ return sync_detailed( @@ -86,7 +86,7 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], -) -> Response[List[str]]: +) -> Response[list[str]]: """Get Basic List Of Strings Get a list of strings @@ -96,7 +96,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List[str]] + Response[list[str]] """ kwargs = _get_kwargs() @@ -109,7 +109,7 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], -) -> Optional[List[str]]: +) -> Optional[list[str]]: """Get Basic List Of Strings Get a list of strings @@ -119,7 +119,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List[str] + list[str] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py index 444657982..a708cf71d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/get_user_list.py @@ -1,6 +1,6 @@ import datetime from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx @@ -15,12 +15,12 @@ def _get_kwargs( *, - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], some_date: Union[datetime.date, datetime.datetime], -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} json_an_enum_value = [] for an_enum_value_item_data in an_enum_value: @@ -54,7 +54,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/", "params": params, @@ -65,7 +65,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -91,7 +91,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +) -> Response[Union[HTTPValidationError, list["AModel"]]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -103,19 +103,19 @@ def _build_response( def sync_detailed( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], some_date: Union[datetime.date, datetime.datetime], -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +) -> Response[Union[HTTPValidationError, list["AModel"]]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): some_date (Union[datetime.date, datetime.datetime]): Raises: @@ -123,7 +123,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[Union[HTTPValidationError, list['AModel']]] """ kwargs = _get_kwargs( @@ -143,19 +143,19 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], some_date: Union[datetime.date, datetime.datetime], -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): some_date (Union[datetime.date, datetime.datetime]): Raises: @@ -163,7 +163,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[HTTPValidationError, List['AModel']] + Union[HTTPValidationError, list['AModel']] """ return sync_detailed( @@ -178,19 +178,19 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], some_date: Union[datetime.date, datetime.datetime], -) -> Response[Union[HTTPValidationError, List["AModel"]]]: +) -> Response[Union[HTTPValidationError, list["AModel"]]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): some_date (Union[datetime.date, datetime.datetime]): Raises: @@ -198,7 +198,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[Union[HTTPValidationError, List['AModel']]] + Response[Union[HTTPValidationError, list['AModel']]] """ kwargs = _get_kwargs( @@ -216,19 +216,19 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], some_date: Union[datetime.date, datetime.datetime], -) -> Optional[Union[HTTPValidationError, List["AModel"]]]: +) -> Optional[Union[HTTPValidationError, list["AModel"]]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): some_date (Union[datetime.date, datetime.datetime]): Raises: @@ -236,7 +236,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Union[HTTPValidationError, List['AModel']] + Union[HTTPValidationError, list['AModel']] """ return ( diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py index b9b17aeac..f33a23dc7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: AModel, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/json_body", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py index f78e06eed..586947f49 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/no_response_tests_no_response_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/no_response", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py index 4810d5ebc..efb0f4ae5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_get.py @@ -1,6 +1,6 @@ from http import HTTPStatus from io import BytesIO -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -9,8 +9,8 @@ from ...types import File, Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/octet_stream", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py index c7faeb15f..ea0cbd65a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/octet_stream_tests_octet_stream_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: File, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/octet_stream", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py index a2e7232c2..ec65d0363 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: AFormData, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/post_form_data", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py index 290e6efdb..bc5ad7cc4 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_form_data_inline.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: PostFormDataInlineBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/post_form_data_inline", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py index bc80281c9..ba40de26f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/post_tests_json_body_string.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: str, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/json_body/string", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py index 07c16c748..287ea4a1a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/test_inline_objects.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: TestInlineObjectsBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/inline_objects", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py index e71ee24e9..22ac00650 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/token_with_cookie_auth_token_with_cookie_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,11 +11,11 @@ def _get_kwargs( *, my_token: str, -) -> Dict[str, Any]: +) -> dict[str, Any]: cookies = {} cookies["MyToken"] = my_token - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/auth/token_with_cookie", "cookies": cookies, diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py index e22ed5125..61e8434e6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/unsupported_content_tests_unsupported_content_get.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -8,8 +8,8 @@ from ...types import Response -def _get_kwargs() -> Dict[str, Any]: - _kwargs: Dict[str, Any] = { +def _get_kwargs() -> dict[str, Any]: + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/unsupported_content", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py index 88b305101..9f1864ec3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: BodyUploadFileTestsUploadPost, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/upload", } diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py index 098ae7a13..3f8edc817 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_multiple_files_tests_upload_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,11 +11,11 @@ def _get_kwargs( *, - body: List[File], -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} + body: list[File], +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/upload/multiple", } @@ -62,14 +62,14 @@ def _build_response( def sync_detailed( *, client: Union[AuthenticatedClient, Client], - body: List[File], + body: list[File], ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files Upload several files in the same request Args: - body (List[File]): + body (list[File]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -93,14 +93,14 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], - body: List[File], + body: list[File], ) -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files Upload several files in the same request Args: - body (List[File]): + body (list[File]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -119,14 +119,14 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], - body: List[File], + body: list[File], ) -> Response[Union[Any, HTTPValidationError]]: """Upload multiple files Upload several files in the same request Args: - body (List[File]): + body (list[File]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -148,14 +148,14 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], - body: List[File], + body: list[File], ) -> Optional[Union[Any, HTTPValidationError]]: """Upload multiple files Upload several files in the same request Args: - body (List[File]): + body (list[File]): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py index 891485f62..b46550153 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/api/true_/false_.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,14 +11,14 @@ def _get_kwargs( *, import_: str, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["import"] = import_ params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/naming/keywords", "params": params, diff --git a/end_to_end_tests/golden-record/my_test_api_client/client.py b/end_to_end_tests/golden-record/my_test_api_client/client.py index 0f6d15e84..e80446f10 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/golden-record/my_test_api_client/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx from attrs import define, evolve, field @@ -36,16 +36,16 @@ class Client: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - def with_headers(self, headers: Dict[str, str]) -> "Client": + def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -53,7 +53,7 @@ def with_headers(self, headers: Dict[str, str]) -> "Client": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "Client": + def with_cookies(self, cookies: dict[str, str]) -> "Client": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) @@ -166,12 +166,12 @@ class AuthenticatedClient: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -179,7 +179,7 @@ class AuthenticatedClient: prefix: str = "Bearer" auth_header_name: str = "Authorization" - def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -187,7 +187,7 @@ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_1.py index cb1184b18..efdee8d2b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_1.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class ADiscriminatedUnionType1: """ model_type: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: model_type = self.model_type - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if model_type is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_type = d.pop("modelType", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return a_discriminated_union_type_1 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_2.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_2.py index 734f3bef4..02f4870e6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_2.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_2.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class ADiscriminatedUnionType2: """ model_type: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: model_type = self.model_type - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if model_type is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_type = d.pop("modelType", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return a_discriminated_union_type_2 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py index a4c5cd8a7..12c57c3bc 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class AFormData: an_required_field: str an_optional_field: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: an_required_field = self.an_required_field an_optional_field = self.an_optional_field - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -38,7 +38,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() an_required_field = d.pop("an_required_field") @@ -53,7 +53,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return a_form_data @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py index a14400c9d..5a81e6365 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model.py @@ -1,5 +1,5 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from uuid import UUID from attrs import define as _attrs_define @@ -38,7 +38,7 @@ class AModel: nullable_model (Union['ModelWithUnionProperty', None]): any_value (Union[Unset, Any]): Default: 'default'. an_optional_allof_enum (Union[Unset, AnAllOfEnum]): - nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]): + nested_list_of_enums (Union[Unset, list[list[DifferentEnum]]]): a_not_required_date (Union[Unset, datetime.date]): a_not_required_uuid (Union[Unset, UUID]): attr_1_leading_digit (Union[Unset, str]): @@ -66,7 +66,7 @@ class AModel: a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") any_value: Union[Unset, Any] = "default" an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET a_not_required_date: Union[Unset, datetime.date] = UNSET a_not_required_uuid: Union[Unset, UUID] = UNSET attr_1_leading_digit: Union[Unset, str] = UNSET @@ -78,7 +78,7 @@ class AModel: not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.free_form_model import FreeFormModel from ..models.model_with_union_property import ModelWithUnionProperty @@ -113,7 +113,7 @@ def to_dict(self) -> Dict[str, Any]: required_not_nullable = self.required_not_nullable - one_of_models: Union[Any, Dict[str, Any]] + one_of_models: Union[Any, dict[str, Any]] if isinstance(self.one_of_models, FreeFormModel): one_of_models = self.one_of_models.to_dict() elif isinstance(self.one_of_models, ModelWithUnionProperty): @@ -121,7 +121,7 @@ def to_dict(self) -> Dict[str, Any]: else: one_of_models = self.one_of_models - nullable_one_of_models: Union[Dict[str, Any], None] + nullable_one_of_models: Union[None, dict[str, Any]] if isinstance(self.nullable_one_of_models, FreeFormModel): nullable_one_of_models = self.nullable_one_of_models.to_dict() elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): @@ -131,7 +131,7 @@ def to_dict(self) -> Dict[str, Any]: model = self.model.to_dict() - nullable_model: Union[Dict[str, Any], None] + nullable_model: Union[None, dict[str, Any]] if isinstance(self.nullable_model, ModelWithUnionProperty): nullable_model = self.nullable_model.to_dict() else: @@ -143,7 +143,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.an_optional_allof_enum, Unset): an_optional_allof_enum = self.an_optional_allof_enum.value - nested_list_of_enums: Union[Unset, List[List[str]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET if not isinstance(self.nested_list_of_enums, Unset): nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: @@ -174,7 +174,7 @@ def to_dict(self) -> Dict[str, Any]: not_required_not_nullable = self.not_required_not_nullable - not_required_one_of_models: Union[Dict[str, Any], Unset] + not_required_one_of_models: Union[Unset, dict[str, Any]] if isinstance(self.not_required_one_of_models, Unset): not_required_one_of_models = UNSET elif isinstance(self.not_required_one_of_models, FreeFormModel): @@ -182,7 +182,7 @@ def to_dict(self) -> Dict[str, Any]: else: not_required_one_of_models = self.not_required_one_of_models.to_dict() - not_required_nullable_one_of_models: Union[Dict[str, Any], None, Unset, str] + not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] if isinstance(self.not_required_nullable_one_of_models, Unset): not_required_nullable_one_of_models = UNSET elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): @@ -192,11 +192,11 @@ def to_dict(self) -> Dict[str, Any]: else: not_required_nullable_one_of_models = self.not_required_nullable_one_of_models - not_required_model: Union[Unset, Dict[str, Any]] = UNSET + not_required_model: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.not_required_model, Unset): not_required_model = self.not_required_model.to_dict() - not_required_nullable_model: Union[Dict[str, Any], None, Unset] + not_required_nullable_model: Union[None, Unset, dict[str, Any]] if isinstance(self.not_required_nullable_model, Unset): not_required_nullable_model = UNSET elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): @@ -204,7 +204,7 @@ def to_dict(self) -> Dict[str, Any]: else: not_required_nullable_model = self.not_required_nullable_model - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update( { "an_enum_value": an_enum_value, @@ -252,7 +252,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.free_form_model import FreeFormModel from ..models.model_with_union_property import ModelWithUnionProperty diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py index 88ffd349f..c1a905195 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -1,6 +1,6 @@ import datetime from io import BytesIO -from typing import Any, Dict, List, Type, TypeVar, cast +from typing import Any, TypeVar, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,26 +16,26 @@ class AModelWithPropertiesReferenceThatAreNotObject: """ Attributes: - enum_properties_ref (List[AnEnum]): - str_properties_ref (List[str]): - date_properties_ref (List[datetime.date]): - datetime_properties_ref (List[datetime.datetime]): - int32_properties_ref (List[int]): - int64_properties_ref (List[int]): - float_properties_ref (List[float]): - double_properties_ref (List[float]): - file_properties_ref (List[File]): - bytestream_properties_ref (List[str]): - enum_properties (List[AnEnum]): - str_properties (List[str]): - date_properties (List[datetime.date]): - datetime_properties (List[datetime.datetime]): - int32_properties (List[int]): - int64_properties (List[int]): - float_properties (List[float]): - double_properties (List[float]): - file_properties (List[File]): - bytestream_properties (List[str]): + enum_properties_ref (list[AnEnum]): + str_properties_ref (list[str]): + date_properties_ref (list[datetime.date]): + datetime_properties_ref (list[datetime.datetime]): + int32_properties_ref (list[int]): + int64_properties_ref (list[int]): + float_properties_ref (list[float]): + double_properties_ref (list[float]): + file_properties_ref (list[File]): + bytestream_properties_ref (list[str]): + enum_properties (list[AnEnum]): + str_properties (list[str]): + date_properties (list[datetime.date]): + datetime_properties (list[datetime.datetime]): + int32_properties (list[int]): + int64_properties (list[int]): + float_properties (list[float]): + double_properties (list[float]): + file_properties (list[File]): + bytestream_properties (list[str]): enum_property_ref (AnEnum): For testing Enums in all the ways they can be used str_property_ref (str): date_property_ref (datetime.date): @@ -48,26 +48,26 @@ class AModelWithPropertiesReferenceThatAreNotObject: bytestream_property_ref (str): """ - enum_properties_ref: List[AnEnum] - str_properties_ref: List[str] - date_properties_ref: List[datetime.date] - datetime_properties_ref: List[datetime.datetime] - int32_properties_ref: List[int] - int64_properties_ref: List[int] - float_properties_ref: List[float] - double_properties_ref: List[float] - file_properties_ref: List[File] - bytestream_properties_ref: List[str] - enum_properties: List[AnEnum] - str_properties: List[str] - date_properties: List[datetime.date] - datetime_properties: List[datetime.datetime] - int32_properties: List[int] - int64_properties: List[int] - float_properties: List[float] - double_properties: List[float] - file_properties: List[File] - bytestream_properties: List[str] + enum_properties_ref: list[AnEnum] + str_properties_ref: list[str] + date_properties_ref: list[datetime.date] + datetime_properties_ref: list[datetime.datetime] + int32_properties_ref: list[int] + int64_properties_ref: list[int] + float_properties_ref: list[float] + double_properties_ref: list[float] + file_properties_ref: list[File] + bytestream_properties_ref: list[str] + enum_properties: list[AnEnum] + str_properties: list[str] + date_properties: list[datetime.date] + datetime_properties: list[datetime.datetime] + int32_properties: list[int] + int64_properties: list[int] + float_properties: list[float] + double_properties: list[float] + file_properties: list[File] + bytestream_properties: list[str] enum_property_ref: AnEnum str_property_ref: str date_property_ref: datetime.date @@ -78,9 +78,9 @@ class AModelWithPropertiesReferenceThatAreNotObject: double_property_ref: float file_property_ref: File bytestream_property_ref: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: enum_properties_ref = [] for componentsschemas_an_other_array_of_enum_item_data in self.enum_properties_ref: componentsschemas_an_other_array_of_enum_item = componentsschemas_an_other_array_of_enum_item_data.value @@ -173,7 +173,7 @@ def to_dict(self) -> Dict[str, Any]: bytestream_property_ref = self.bytestream_property_ref - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -213,7 +213,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() enum_properties_ref = [] _enum_properties_ref = d.pop("enum_properties_ref") @@ -222,7 +222,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: enum_properties_ref.append(componentsschemas_an_other_array_of_enum_item) - str_properties_ref = cast(List[str], d.pop("str_properties_ref")) + str_properties_ref = cast(list[str], d.pop("str_properties_ref")) date_properties_ref = [] _date_properties_ref = d.pop("date_properties_ref") @@ -242,13 +242,13 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: datetime_properties_ref.append(componentsschemas_an_other_array_of_date_time_item) - int32_properties_ref = cast(List[int], d.pop("int32_properties_ref")) + int32_properties_ref = cast(list[int], d.pop("int32_properties_ref")) - int64_properties_ref = cast(List[int], d.pop("int64_properties_ref")) + int64_properties_ref = cast(list[int], d.pop("int64_properties_ref")) - float_properties_ref = cast(List[float], d.pop("float_properties_ref")) + float_properties_ref = cast(list[float], d.pop("float_properties_ref")) - double_properties_ref = cast(List[float], d.pop("double_properties_ref")) + double_properties_ref = cast(list[float], d.pop("double_properties_ref")) file_properties_ref = [] _file_properties_ref = d.pop("file_properties_ref") @@ -259,7 +259,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: file_properties_ref.append(componentsschemas_an_other_array_of_file_item) - bytestream_properties_ref = cast(List[str], d.pop("bytestream_properties_ref")) + bytestream_properties_ref = cast(list[str], d.pop("bytestream_properties_ref")) enum_properties = [] _enum_properties = d.pop("enum_properties") @@ -268,7 +268,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: enum_properties.append(componentsschemas_an_array_of_enum_item) - str_properties = cast(List[str], d.pop("str_properties")) + str_properties = cast(list[str], d.pop("str_properties")) date_properties = [] _date_properties = d.pop("date_properties") @@ -284,13 +284,13 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: datetime_properties.append(componentsschemas_an_array_of_date_time_item) - int32_properties = cast(List[int], d.pop("int32_properties")) + int32_properties = cast(list[int], d.pop("int32_properties")) - int64_properties = cast(List[int], d.pop("int64_properties")) + int64_properties = cast(list[int], d.pop("int64_properties")) - float_properties = cast(List[float], d.pop("float_properties")) + float_properties = cast(list[float], d.pop("float_properties")) - double_properties = cast(List[float], d.pop("double_properties")) + double_properties = cast(list[float], d.pop("double_properties")) file_properties = [] _file_properties = d.pop("file_properties") @@ -301,7 +301,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: file_properties.append(componentsschemas_an_array_of_file_item) - bytestream_properties = cast(List[str], d.pop("bytestream_properties")) + bytestream_properties = cast(list[str], d.pop("bytestream_properties")) enum_property_ref = AnEnum(d.pop("enum_property_ref")) @@ -360,7 +360,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return a_model_with_properties_reference_that_are_not_object @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py index 245a1b04a..6a39f4951 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,42 +14,42 @@ class AllOfHasPropertiesButNoType: """ Attributes: a_sub_property (Union[Unset, str]): - type (Union[Unset, str]): + type_ (Union[Unset, str]): type_enum (Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum]): """ a_sub_property: Union[Unset, str] = UNSET - type: Union[Unset, str] = UNSET + type_: Union[Unset, str] = UNSET type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property - type = self.type + type_ = self.type_ type_enum: Union[Unset, int] = UNSET if not isinstance(self.type_enum, Unset): type_enum = self.type_enum.value - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a_sub_property is not UNSET: field_dict["a_sub_property"] = a_sub_property - if type is not UNSET: - field_dict["type"] = type + if type_ is not UNSET: + field_dict["type"] = type_ if type_enum is not UNSET: field_dict["type_enum"] = type_enum return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_sub_property = d.pop("a_sub_property", UNSET) - type = d.pop("type", UNSET) + type_ = d.pop("type", UNSET) _type_enum = d.pop("type_enum", UNSET) type_enum: Union[Unset, AllOfHasPropertiesButNoTypeTypeEnum] @@ -60,7 +60,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: all_of_has_properties_but_no_type = cls( a_sub_property=a_sub_property, - type=type, + type_=type_, type_enum=type_enum, ) @@ -68,7 +68,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return all_of_has_properties_but_no_type @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py index 550b9b9c4..dfb672ce1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,42 +14,42 @@ class AllOfSubModel: """ Attributes: a_sub_property (Union[Unset, str]): - type (Union[Unset, str]): + type_ (Union[Unset, str]): type_enum (Union[Unset, AllOfSubModelTypeEnum]): """ a_sub_property: Union[Unset, str] = UNSET - type: Union[Unset, str] = UNSET + type_: Union[Unset, str] = UNSET type_enum: Union[Unset, AllOfSubModelTypeEnum] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property - type = self.type + type_ = self.type_ type_enum: Union[Unset, int] = UNSET if not isinstance(self.type_enum, Unset): type_enum = self.type_enum.value - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a_sub_property is not UNSET: field_dict["a_sub_property"] = a_sub_property - if type is not UNSET: - field_dict["type"] = type + if type_ is not UNSET: + field_dict["type"] = type_ if type_enum is not UNSET: field_dict["type_enum"] = type_enum return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_sub_property = d.pop("a_sub_property", UNSET) - type = d.pop("type", UNSET) + type_ = d.pop("type", UNSET) _type_enum = d.pop("type_enum", UNSET) type_enum: Union[Unset, AllOfSubModelTypeEnum] @@ -60,7 +60,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: all_of_sub_model = cls( a_sub_property=a_sub_property, - type=type, + type_=type_, type_enum=type_enum, ) @@ -68,7 +68,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return all_of_sub_model @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py index b7792fefc..02e9cfa4b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,14 +16,14 @@ class AnArrayWithACircularRefInItemsObjectAItem: """ Attributes: - circular (Union[Unset, List['AnArrayWithACircularRefInItemsObjectBItem']]): + circular (Union[Unset, list['AnArrayWithACircularRefInItemsObjectBItem']]): """ - circular: Union[Unset, List["AnArrayWithACircularRefInItemsObjectBItem"]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectBItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - circular: Union[Unset, List[Dict[str, Any]]] = UNSET + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.circular, Unset): circular = [] for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in self.circular: @@ -32,7 +32,7 @@ def to_dict(self) -> Dict[str, Any]: ) circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if circular is not UNSET: @@ -41,7 +41,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_b_item import ( AnArrayWithACircularRefInItemsObjectBItem, ) @@ -66,7 +66,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_circular_ref_in_items_object_a_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py index c505553b6..c72c0160a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem: """ """ - additional_properties: Dict[str, List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]] = ( + additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]] = ( _attrs_field(init=False, factory=dict) ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] for ( @@ -35,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, ) @@ -68,14 +68,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_circular_ref_in_items_object_additional_properties_a_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: + def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] + self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem"] ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py index 9d2dc9827..7ffb50a16 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem: """ """ - additional_properties: Dict[str, List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]] = ( + additional_properties: dict[str, list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]] = ( _attrs_field(init=False, factory=dict) ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] for ( @@ -35,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, ) @@ -68,14 +68,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_circular_ref_in_items_object_additional_properties_b_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: + def __getitem__(self, key: str) -> list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: List["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] + self, key: str, value: list["AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem"] ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py index 622d5d999..6d5e83a65 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,14 +16,14 @@ class AnArrayWithACircularRefInItemsObjectBItem: """ Attributes: - circular (Union[Unset, List['AnArrayWithACircularRefInItemsObjectAItem']]): + circular (Union[Unset, list['AnArrayWithACircularRefInItemsObjectAItem']]): """ - circular: Union[Unset, List["AnArrayWithACircularRefInItemsObjectAItem"]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + circular: Union[Unset, list["AnArrayWithACircularRefInItemsObjectAItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - circular: Union[Unset, List[Dict[str, Any]]] = UNSET + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.circular, Unset): circular = [] for componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item_data in self.circular: @@ -32,7 +32,7 @@ def to_dict(self) -> Dict[str, Any]: ) circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if circular is not UNSET: @@ -41,7 +41,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_a_item import ( AnArrayWithACircularRefInItemsObjectAItem, ) @@ -66,7 +66,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_circular_ref_in_items_object_b_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py index e19cfc052..14dc6ba26 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,12 +10,12 @@ class AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem: """ """ - additional_properties: Dict[str, List["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]] = ( + additional_properties: dict[str, list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]] = ( _attrs_field(init=False, factory=dict) ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = [] for componentsschemas_an_array_with_a_recursive_ref_in_items_object_additional_properties_item_data in prop: @@ -27,7 +27,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() an_array_with_a_recursive_ref_in_items_object_additional_properties_item = cls() @@ -56,14 +56,14 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_recursive_ref_in_items_object_additional_properties_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) - def __getitem__(self, key: str) -> List["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: + def __getitem__(self, key: str) -> list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"]: return self.additional_properties[key] def __setitem__( - self, key: str, value: List["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] + self, key: str, value: list["AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem"] ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py index 6b12b9b5d..c8629e83d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,14 +12,14 @@ class AnArrayWithARecursiveRefInItemsObjectItem: """ Attributes: - recursive (Union[Unset, List['AnArrayWithARecursiveRefInItemsObjectItem']]): + recursive (Union[Unset, list['AnArrayWithARecursiveRefInItemsObjectItem']]): """ - recursive: Union[Unset, List["AnArrayWithARecursiveRefInItemsObjectItem"]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + recursive: Union[Unset, list["AnArrayWithARecursiveRefInItemsObjectItem"]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - recursive: Union[Unset, List[Dict[str, Any]]] = UNSET + def to_dict(self) -> dict[str, Any]: + recursive: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.recursive, Unset): recursive = [] for componentsschemas_an_array_with_a_recursive_ref_in_items_object_item_data in self.recursive: @@ -28,7 +28,7 @@ def to_dict(self) -> Dict[str, Any]: ) recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if recursive is not UNSET: @@ -37,7 +37,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() recursive = [] _recursive = d.pop("recursive", UNSET) @@ -58,7 +58,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return an_array_with_a_recursive_ref_in_items_object_item @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py index fde2bb6f8..df2d9b2cd 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -15,49 +15,49 @@ class AnotherAllOfSubModel: """ Attributes: another_sub_property (Union[Unset, str]): - type (Union[Unset, AnotherAllOfSubModelType]): + type_ (Union[Unset, AnotherAllOfSubModelType]): type_enum (Union[Unset, AnotherAllOfSubModelTypeEnum]): """ another_sub_property: Union[Unset, str] = UNSET - type: Union[Unset, AnotherAllOfSubModelType] = UNSET + type_: Union[Unset, AnotherAllOfSubModelType] = UNSET type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: another_sub_property = self.another_sub_property - type: Union[Unset, str] = UNSET - if not isinstance(self.type, Unset): - type = self.type.value + type_: Union[Unset, str] = UNSET + if not isinstance(self.type_, Unset): + type_ = self.type_.value type_enum: Union[Unset, int] = UNSET if not isinstance(self.type_enum, Unset): type_enum = self.type_enum.value - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if another_sub_property is not UNSET: field_dict["another_sub_property"] = another_sub_property - if type is not UNSET: - field_dict["type"] = type + if type_ is not UNSET: + field_dict["type"] = type_ if type_enum is not UNSET: field_dict["type_enum"] = type_enum return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() another_sub_property = d.pop("another_sub_property", UNSET) - _type = d.pop("type", UNSET) - type: Union[Unset, AnotherAllOfSubModelType] - if isinstance(_type, Unset): - type = UNSET + _type_ = d.pop("type", UNSET) + type_: Union[Unset, AnotherAllOfSubModelType] + if isinstance(_type_, Unset): + type_ = UNSET else: - type = AnotherAllOfSubModelType(_type) + type_ = AnotherAllOfSubModelType(_type_) _type_enum = d.pop("type_enum", UNSET) type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] @@ -68,7 +68,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: another_all_of_sub_model = cls( another_sub_property=another_sub_property, - type=type, + type_=type_, type_enum=type_enum, ) @@ -76,7 +76,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return another_all_of_sub_model @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py index d7fbbf835..1c255cfcb 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post.py @@ -1,7 +1,7 @@ import datetime import json from io import BytesIO -from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -41,8 +41,8 @@ class BodyUploadFileTestsUploadPost: a_date (Union[Unset, datetime.date]): some_number (Union[Unset, float]): some_nullable_number (Union[None, Unset, float]): - some_int_array (Union[Unset, List[Union[None, int]]]): - some_array (Union[List['AFormData'], None, Unset]): + some_int_array (Union[Unset, list[Union[None, int]]]): + some_array (Union[None, Unset, list['AFormData']]): some_optional_object (Union[Unset, BodyUploadFileTestsUploadPostSomeOptionalObject]): some_enum (Union[Unset, DifferentEnum]): An enumeration. """ @@ -57,15 +57,15 @@ class BodyUploadFileTestsUploadPost: a_date: Union[Unset, datetime.date] = UNSET some_number: Union[Unset, float] = UNSET some_nullable_number: Union[None, Unset, float] = UNSET - some_int_array: Union[Unset, List[Union[None, int]]] = UNSET - some_array: Union[List["AFormData"], None, Unset] = UNSET + some_int_array: Union[Unset, list[Union[None, int]]] = UNSET + some_array: Union[None, Unset, list["AFormData"]] = UNSET some_optional_object: Union[Unset, "BodyUploadFileTestsUploadPostSomeOptionalObject"] = UNSET some_enum: Union[Unset, DifferentEnum] = UNSET - additional_properties: Dict[str, "BodyUploadFileTestsUploadPostAdditionalProperty"] = _attrs_field( + additional_properties: dict[str, "BodyUploadFileTestsUploadPostAdditionalProperty"] = _attrs_field( init=False, factory=dict ) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( BodyUploadFileTestsUploadPostSomeNullableObject, ) @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: some_object = self.some_object.to_dict() - some_nullable_object: Union[Dict[str, Any], None] + some_nullable_object: Union[None, dict[str, Any]] if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): some_nullable_object = self.some_nullable_object.to_dict() else: @@ -104,7 +104,7 @@ def to_dict(self) -> Dict[str, Any]: else: some_nullable_number = self.some_nullable_number - some_int_array: Union[Unset, List[Union[None, int]]] = UNSET + some_int_array: Union[Unset, list[Union[None, int]]] = UNSET if not isinstance(self.some_int_array, Unset): some_int_array = [] for some_int_array_item_data in self.some_int_array: @@ -112,7 +112,7 @@ def to_dict(self) -> Dict[str, Any]: some_int_array_item = some_int_array_item_data some_int_array.append(some_int_array_item) - some_array: Union[List[Dict[str, Any]], None, Unset] + some_array: Union[None, Unset, list[dict[str, Any]]] if isinstance(self.some_array, Unset): some_array = UNSET elif isinstance(self.some_array, list): @@ -124,7 +124,7 @@ def to_dict(self) -> Dict[str, Any]: else: some_array = self.some_array - some_optional_object: Union[Unset, Dict[str, Any]] = UNSET + some_optional_object: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.some_optional_object, Unset): some_optional_object = self.some_optional_object.to_dict() @@ -132,7 +132,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.some_enum, Unset): some_enum = self.some_enum.value - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() field_dict.update( @@ -166,14 +166,14 @@ def to_dict(self) -> Dict[str, Any]: return field_dict - def to_multipart(self) -> Dict[str, Any]: + def to_multipart(self) -> dict[str, Any]: some_file = self.some_file.to_tuple() some_required_number = (None, str(self.some_required_number).encode(), "text/plain") some_object = (None, json.dumps(self.some_object.to_dict()).encode(), "application/json") - some_nullable_object: Tuple[None, bytes, str] + some_nullable_object: tuple[None, bytes, str] if isinstance(self.some_nullable_object, BodyUploadFileTestsUploadPostSomeNullableObject): some_nullable_object = (None, json.dumps(self.some_nullable_object.to_dict()).encode(), "application/json") @@ -204,7 +204,7 @@ def to_multipart(self) -> Dict[str, Any]: else (None, str(self.some_number).encode(), "text/plain") ) - some_nullable_number: Union[Tuple[None, bytes, str], Unset] + some_nullable_number: Union[Unset, tuple[None, bytes, str]] if isinstance(self.some_nullable_number, Unset): some_nullable_number = UNSET @@ -213,7 +213,7 @@ def to_multipart(self) -> Dict[str, Any]: else: some_nullable_number = (None, str(self.some_nullable_number).encode(), "text/plain") - some_int_array: Union[Unset, Tuple[None, bytes, str]] = UNSET + some_int_array: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.some_int_array, Unset): _temp_some_int_array = [] for some_int_array_item_data in self.some_int_array: @@ -222,7 +222,7 @@ def to_multipart(self) -> Dict[str, Any]: _temp_some_int_array.append(some_int_array_item) some_int_array = (None, json.dumps(_temp_some_int_array).encode(), "application/json") - some_array: Union[Tuple[None, bytes, str], Unset] + some_array: Union[Unset, tuple[None, bytes, str]] if isinstance(self.some_array, Unset): some_array = UNSET @@ -235,15 +235,15 @@ def to_multipart(self) -> Dict[str, Any]: else: some_array = (None, str(self.some_array).encode(), "text/plain") - some_optional_object: Union[Unset, Tuple[None, bytes, str]] = UNSET + some_optional_object: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.some_optional_object, Unset): some_optional_object = (None, json.dumps(self.some_optional_object.to_dict()).encode(), "application/json") - some_enum: Union[Unset, Tuple[None, bytes, str]] = UNSET + some_enum: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.some_enum, Unset): some_enum = (None, str(self.some_enum.value).encode(), "text/plain") - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = (None, json.dumps(prop.to_dict()).encode(), "application/json") field_dict.update( @@ -278,7 +278,7 @@ def to_multipart(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.a_form_data import AFormData from ..models.body_upload_file_tests_upload_post_additional_property import ( BodyUploadFileTestsUploadPostAdditionalProperty, @@ -360,7 +360,7 @@ def _parse_some_int_array_item(data: object) -> Union[None, int]: some_int_array.append(some_int_array_item) - def _parse_some_array(data: object) -> Union[List["AFormData"], None, Unset]: + def _parse_some_array(data: object) -> Union[None, Unset, list["AFormData"]]: if data is None: return data if isinstance(data, Unset): @@ -378,7 +378,7 @@ def _parse_some_array(data: object) -> Union[List["AFormData"], None, Unset]: return some_array_type_0 except: # noqa: E722 pass - return cast(Union[List["AFormData"], None, Unset], data) + return cast(Union[None, Unset, list["AFormData"]], data) some_array = _parse_some_array(d.pop("some_array", UNSET)) @@ -423,7 +423,7 @@ def _parse_some_array(data: object) -> Union[List["AFormData"], None, Unset]: return body_upload_file_tests_upload_post @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> "BodyUploadFileTestsUploadPostAdditionalProperty": diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py index f855d9c61..47dde1338 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class BodyUploadFileTestsUploadPostAdditionalProperty: """ foo: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: foo = self.foo - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if foo is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() foo = d.pop("foo", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return body_upload_file_tests_upload_post_additional_property @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py index 9762b7efa..817dfd789 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class BodyUploadFileTestsUploadPostSomeNullableObject: """ bar: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: bar = self.bar - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if bar is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() bar = d.pop("bar", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return body_upload_file_tests_upload_post_some_nullable_object @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py index 25c2c0a6a..a074bb86f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,14 +16,14 @@ class BodyUploadFileTestsUploadPostSomeObject: num: float text: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: num = self.num text = self.text - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -35,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() num = d.pop("num") @@ -50,7 +50,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return body_upload_file_tests_upload_post_some_object @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py index 711b34e63..e0ba4b364 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,12 +14,12 @@ class BodyUploadFileTestsUploadPostSomeOptionalObject: """ foo: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: foo = self.foo - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() foo = d.pop("foo") @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return body_upload_file_tests_upload_post_some_optional_object @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/extended.py b/end_to_end_tests/golden-record/my_test_api_client/models/extended.py index 324513d3a..ffd6406c7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/extended.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/extended.py @@ -1,5 +1,5 @@ import datetime -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from uuid import UUID from attrs import define as _attrs_define @@ -38,7 +38,7 @@ class Extended: nullable_model (Union['ModelWithUnionProperty', None]): any_value (Union[Unset, Any]): Default: 'default'. an_optional_allof_enum (Union[Unset, AnAllOfEnum]): - nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]): + nested_list_of_enums (Union[Unset, list[list[DifferentEnum]]]): a_not_required_date (Union[Unset, datetime.date]): a_not_required_uuid (Union[Unset, UUID]): attr_1_leading_digit (Union[Unset, str]): @@ -67,7 +67,7 @@ class Extended: a_nullable_uuid: Union[None, UUID] = UUID("07EF8B4D-AA09-4FFA-898D-C710796AFF41") any_value: Union[Unset, Any] = "default" an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET a_not_required_date: Union[Unset, datetime.date] = UNSET a_not_required_uuid: Union[Unset, UUID] = UNSET attr_1_leading_digit: Union[Unset, str] = UNSET @@ -79,9 +79,9 @@ class Extended: not_required_model: Union[Unset, "ModelWithUnionProperty"] = UNSET not_required_nullable_model: Union["ModelWithUnionProperty", None, Unset] = UNSET from_extended: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.free_form_model import FreeFormModel from ..models.model_with_union_property import ModelWithUnionProperty @@ -116,7 +116,7 @@ def to_dict(self) -> Dict[str, Any]: required_not_nullable = self.required_not_nullable - one_of_models: Union[Any, Dict[str, Any]] + one_of_models: Union[Any, dict[str, Any]] if isinstance(self.one_of_models, FreeFormModel): one_of_models = self.one_of_models.to_dict() elif isinstance(self.one_of_models, ModelWithUnionProperty): @@ -124,7 +124,7 @@ def to_dict(self) -> Dict[str, Any]: else: one_of_models = self.one_of_models - nullable_one_of_models: Union[Dict[str, Any], None] + nullable_one_of_models: Union[None, dict[str, Any]] if isinstance(self.nullable_one_of_models, FreeFormModel): nullable_one_of_models = self.nullable_one_of_models.to_dict() elif isinstance(self.nullable_one_of_models, ModelWithUnionProperty): @@ -134,7 +134,7 @@ def to_dict(self) -> Dict[str, Any]: model = self.model.to_dict() - nullable_model: Union[Dict[str, Any], None] + nullable_model: Union[None, dict[str, Any]] if isinstance(self.nullable_model, ModelWithUnionProperty): nullable_model = self.nullable_model.to_dict() else: @@ -146,7 +146,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.an_optional_allof_enum, Unset): an_optional_allof_enum = self.an_optional_allof_enum.value - nested_list_of_enums: Union[Unset, List[List[str]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET if not isinstance(self.nested_list_of_enums, Unset): nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: @@ -177,7 +177,7 @@ def to_dict(self) -> Dict[str, Any]: not_required_not_nullable = self.not_required_not_nullable - not_required_one_of_models: Union[Dict[str, Any], Unset] + not_required_one_of_models: Union[Unset, dict[str, Any]] if isinstance(self.not_required_one_of_models, Unset): not_required_one_of_models = UNSET elif isinstance(self.not_required_one_of_models, FreeFormModel): @@ -185,7 +185,7 @@ def to_dict(self) -> Dict[str, Any]: else: not_required_one_of_models = self.not_required_one_of_models.to_dict() - not_required_nullable_one_of_models: Union[Dict[str, Any], None, Unset, str] + not_required_nullable_one_of_models: Union[None, Unset, dict[str, Any], str] if isinstance(self.not_required_nullable_one_of_models, Unset): not_required_nullable_one_of_models = UNSET elif isinstance(self.not_required_nullable_one_of_models, FreeFormModel): @@ -195,11 +195,11 @@ def to_dict(self) -> Dict[str, Any]: else: not_required_nullable_one_of_models = self.not_required_nullable_one_of_models - not_required_model: Union[Unset, Dict[str, Any]] = UNSET + not_required_model: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.not_required_model, Unset): not_required_model = self.not_required_model.to_dict() - not_required_nullable_model: Union[Dict[str, Any], None, Unset] + not_required_nullable_model: Union[None, Unset, dict[str, Any]] if isinstance(self.not_required_nullable_model, Unset): not_required_nullable_model = UNSET elif isinstance(self.not_required_nullable_model, ModelWithUnionProperty): @@ -209,7 +209,7 @@ def to_dict(self) -> Dict[str, Any]: from_extended = self.from_extended - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -260,7 +260,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.free_form_model import FreeFormModel from ..models.model_with_union_property import ModelWithUnionProperty @@ -548,7 +548,7 @@ def _parse_not_required_nullable_model(data: object) -> Union["ModelWithUnionPro return extended @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py b/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py index f757b10ae..10770503b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/free_form_model.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class FreeFormModel: """ """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() free_form_model = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return free_form_model @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_allof_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_allof_response_200.py index 2662dc1f4..5e24734e3 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_allof_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_allof_response_200.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -25,22 +25,22 @@ class GetModelsAllofResponse200: aliased: Union[Unset, "AModel"] = UNSET extended: Union[Unset, "Extended"] = UNSET model: Union[Unset, "AModel"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - aliased: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + aliased: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.aliased, Unset): aliased = self.aliased.to_dict() - extended: Union[Unset, Dict[str, Any]] = UNSET + extended: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.extended, Unset): extended = self.extended.to_dict() - model: Union[Unset, Dict[str, Any]] = UNSET + model: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.model, Unset): model = self.model.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if aliased is not UNSET: @@ -53,7 +53,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.a_model import AModel from ..models.extended import Extended @@ -89,7 +89,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return get_models_allof_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py index 972e1c765..18c1e9e64 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Literal, Type, TypeVar, Union, cast +from typing import Any, Literal, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,24 +12,24 @@ class GetModelsOneofWithRequiredConstResponse200Type0: """ Attributes: - type (Literal['alpha']): + type_ (Literal['alpha']): color (Union[Unset, str]): """ - type: Literal["alpha"] + type_: Literal["alpha"] color: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - type = self.type + def to_dict(self) -> dict[str, Any]: + type_ = self.type_ color = self.color - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "type": type, + "type": type_, } ) if color is not UNSET: @@ -38,16 +38,16 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() - type = cast(Literal["alpha"], d.pop("type")) - if type != "alpha": - raise ValueError(f"type must match const 'alpha', got '{type}'") + type_ = cast(Literal["alpha"], d.pop("type")) + if type_ != "alpha": + raise ValueError(f"type must match const 'alpha', got '{type_}'") color = d.pop("color", UNSET) get_models_oneof_with_required_const_response_200_type_0 = cls( - type=type, + type_=type_, color=color, ) @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return get_models_oneof_with_required_const_response_200_type_0 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py index 4596c3cc4..b1df54c32 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Literal, Type, TypeVar, Union, cast +from typing import Any, Literal, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,24 +12,24 @@ class GetModelsOneofWithRequiredConstResponse200Type1: """ Attributes: - type (Literal['beta']): + type_ (Literal['beta']): texture (Union[Unset, str]): """ - type: Literal["beta"] + type_: Literal["beta"] texture: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - type = self.type + def to_dict(self) -> dict[str, Any]: + type_ = self.type_ texture = self.texture - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "type": type, + "type": type_, } ) if texture is not UNSET: @@ -38,16 +38,16 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() - type = cast(Literal["beta"], d.pop("type")) - if type != "beta": - raise ValueError(f"type must match const 'beta', got '{type}'") + type_ = cast(Literal["beta"], d.pop("type")) + if type_ != "beta": + raise ValueError(f"type must match const 'beta', got '{type_}'") texture = d.pop("texture", UNSET) get_models_oneof_with_required_const_response_200_type_1 = cls( - type=type, + type_=type_, texture=texture, ) @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return get_models_oneof_with_required_const_response_200_type_1 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py b/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py index 1f04c29d0..a423c6d2f 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/http_validation_error.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define @@ -15,20 +15,20 @@ class HTTPValidationError: """ Attributes: - detail (Union[Unset, List['ValidationError']]): + detail (Union[Unset, list['ValidationError']]): """ - detail: Union[Unset, List["ValidationError"]] = UNSET + detail: Union[Unset, list["ValidationError"]] = UNSET - def to_dict(self) -> Dict[str, Any]: - detail: Union[Unset, List[Dict[str, Any]]] = UNSET + def to_dict(self) -> dict[str, Any]: + detail: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.detail, Unset): detail = [] for detail_item_data in self.detail: detail_item = detail_item_data.to_dict() detail.append(detail_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update({}) if detail is not UNSET: field_dict["detail"] = detail @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.validation_error import ValidationError d = src_dict.copy() diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/import_.py b/end_to_end_tests/golden-record/my_test_api_client/models/import_.py index 85cc594e7..79788bf80 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/import_.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/import_.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class Import: """ """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() import_ = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return import_ @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/json_like_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/json_like_body.py index 623dcd848..bb4a31010 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/json_like_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/json_like_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class JsonLikeBody: """ a: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a = self.a - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a = d.pop("a", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return json_like_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/mixed_case_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/mixed_case_response_200.py index 21bdd918d..adb74459d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/mixed_case_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/mixed_case_response_200.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class MixedCaseResponse200: mixed_case: Union[Unset, str] = UNSET mixedCase: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: mixed_case = self.mixed_case mixedCase = self.mixedCase - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if mixed_case is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() mixed_case = d.pop("mixed_case", UNSET) @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return mixed_case_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py index 6414b790d..a9fb59976 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_from_all_of.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -15,23 +15,23 @@ class ModelFromAllOf: """ Attributes: a_sub_property (Union[Unset, str]): - type (Union[Unset, AnotherAllOfSubModelType]): + type_ (Union[Unset, AnotherAllOfSubModelType]): type_enum (Union[Unset, AnotherAllOfSubModelTypeEnum]): another_sub_property (Union[Unset, str]): """ a_sub_property: Union[Unset, str] = UNSET - type: Union[Unset, AnotherAllOfSubModelType] = UNSET + type_: Union[Unset, AnotherAllOfSubModelType] = UNSET type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] = UNSET another_sub_property: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property - type: Union[Unset, str] = UNSET - if not isinstance(self.type, Unset): - type = self.type.value + type_: Union[Unset, str] = UNSET + if not isinstance(self.type_, Unset): + type_ = self.type_.value type_enum: Union[Unset, int] = UNSET if not isinstance(self.type_enum, Unset): @@ -39,13 +39,13 @@ def to_dict(self) -> Dict[str, Any]: another_sub_property = self.another_sub_property - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a_sub_property is not UNSET: field_dict["a_sub_property"] = a_sub_property - if type is not UNSET: - field_dict["type"] = type + if type_ is not UNSET: + field_dict["type"] = type_ if type_enum is not UNSET: field_dict["type_enum"] = type_enum if another_sub_property is not UNSET: @@ -54,16 +54,16 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_sub_property = d.pop("a_sub_property", UNSET) - _type = d.pop("type", UNSET) - type: Union[Unset, AnotherAllOfSubModelType] - if isinstance(_type, Unset): - type = UNSET + _type_ = d.pop("type", UNSET) + type_: Union[Unset, AnotherAllOfSubModelType] + if isinstance(_type_, Unset): + type_ = UNSET else: - type = AnotherAllOfSubModelType(_type) + type_ = AnotherAllOfSubModelType(_type_) _type_enum = d.pop("type_enum", UNSET) type_enum: Union[Unset, AnotherAllOfSubModelTypeEnum] @@ -76,7 +76,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: model_from_all_of = cls( a_sub_property=a_sub_property, - type=type, + type_=type_, type_enum=type_enum, another_sub_property=another_sub_property, ) @@ -85,7 +85,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_from_all_of @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py index 2a86db3a2..6f4eefc36 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_name.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class ModelName: """ """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_name = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_name @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py index a5ff5d211..004ed9b20 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_reference_with_periods.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class ModelReferenceWithPeriods: """A Model with periods in its reference""" - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_reference_with_periods = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_reference_with_periods @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py index 761a43e54..a0cdb4f6a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -22,14 +22,14 @@ class ModelWithAdditionalPropertiesInlined: """ a_number: Union[Unset, float] = UNSET - additional_properties: Dict[str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty"] = _attrs_field( + additional_properties: dict[str, "ModelWithAdditionalPropertiesInlinedAdditionalProperty"] = _attrs_field( init=False, factory=dict ) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_number = self.a_number - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() field_dict.update({}) @@ -39,7 +39,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_additional_properties_inlined_additional_property import ( ModelWithAdditionalPropertiesInlinedAdditionalProperty, ) @@ -61,7 +61,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_additional_properties_inlined @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> "ModelWithAdditionalPropertiesInlinedAdditionalProperty": diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py index e06a94bfc..3bfffaf2c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class ModelWithAdditionalPropertiesInlinedAdditionalProperty: """ extra_props_prop: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: extra_props_prop = self.extra_props_prop - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if extra_props_prop is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() extra_props_prop = d.pop("extra_props_prop", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_additional_properties_inlined_additional_property @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py index b2500f68c..0b80a0076 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,17 +12,17 @@ class ModelWithAdditionalPropertiesRefed: """ """ - additional_properties: Dict[str, AnEnum] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, AnEnum] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.value return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_with_additional_properties_refed = cls() @@ -36,7 +36,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_additional_properties_refed @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> AnEnum: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py index 6e669914a..f71fe7c1e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,16 +16,16 @@ class ModelWithAnyJsonProperties: """ """ - additional_properties: Dict[ - str, Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", List[str], bool, float, int, str] + additional_properties: dict[ + str, Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str] ] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.model_with_any_json_properties_additional_property_type_0 import ( ModelWithAnyJsonPropertiesAdditionalPropertyType0, ) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): if isinstance(prop, ModelWithAnyJsonPropertiesAdditionalPropertyType0): field_dict[prop_name] = prop.to_dict() @@ -38,7 +38,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_any_json_properties_additional_property_type_0 import ( ModelWithAnyJsonPropertiesAdditionalPropertyType0, ) @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: def _parse_additional_property( data: object, - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", List[str], bool, float, int, str]: + ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: try: if not isinstance(data, dict): raise TypeError() @@ -63,13 +63,13 @@ def _parse_additional_property( try: if not isinstance(data, list): raise TypeError() - additional_property_type_1 = cast(List[str], data) + additional_property_type_1 = cast(list[str], data) return additional_property_type_1 except: # noqa: E722 pass return cast( - Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", List[str], bool, float, int, str], data + Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], data ) additional_property = _parse_additional_property(prop_dict) @@ -80,18 +80,18 @@ def _parse_additional_property( return model_with_any_json_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__( self, key: str - ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", List[str], bool, float, int, str]: + ) -> Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str]: return self.additional_properties[key] def __setitem__( self, key: str, - value: Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", List[str], bool, float, int, str], + value: Union["ModelWithAnyJsonPropertiesAdditionalPropertyType0", bool, float, int, list[str], str], ) -> None: self.additional_properties[key] = value diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py index 6ae70905e..65993e8be 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class ModelWithAnyJsonPropertiesAdditionalPropertyType0: """ """ - additional_properties: Dict[str, str] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_with_any_json_properties_additional_property_type_0 = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_any_json_properties_additional_property_type_0 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> str: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py index 5de43ddb9..0b5dfc3b5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_backslash_in_description.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,16 +12,16 @@ class ModelWithBackslashInDescription: """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_with_backslash_in_description = cls() @@ -29,7 +29,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_backslash_in_description @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_a.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_a.py index 73cfb1287..3253c520b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_a.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_a.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,14 +20,14 @@ class ModelWithCircularRefA: """ circular: Union[Unset, "ModelWithCircularRefB"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - circular: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.circular, Unset): circular = self.circular.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if circular is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_circular_ref_b import ModelWithCircularRefB d = src_dict.copy() @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_circular_ref_a @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_b.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_b.py index 0628d89ae..89c3a064c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_b.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_b.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,14 +20,14 @@ class ModelWithCircularRefB: """ circular: Union[Unset, "ModelWithCircularRefA"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - circular: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + circular: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.circular, Unset): circular = self.circular.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if circular is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_circular_ref_a import ModelWithCircularRefA d = src_dict.copy() @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_circular_ref_b @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py index 4f1d59c57..32cb687c7 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,19 +14,19 @@ class ModelWithCircularRefInAdditionalPropertiesA: """ """ - additional_properties: Dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = _attrs_field( + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesB"] = _attrs_field( init=False, factory=dict ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_circular_ref_in_additional_properties_b import ( ModelWithCircularRefInAdditionalPropertiesB, ) @@ -44,7 +44,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_circular_ref_in_additional_properties_a @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesB": diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py index 3f55584e5..d134a94b9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -14,19 +14,19 @@ class ModelWithCircularRefInAdditionalPropertiesB: """ """ - additional_properties: Dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = _attrs_field( + additional_properties: dict[str, "ModelWithCircularRefInAdditionalPropertiesA"] = _attrs_field( init=False, factory=dict ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_circular_ref_in_additional_properties_a import ( ModelWithCircularRefInAdditionalPropertiesA, ) @@ -44,7 +44,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_circular_ref_in_additional_properties_b @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> "ModelWithCircularRefInAdditionalPropertiesA": diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_date_time_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_date_time_property.py index 658b2352d..f503af00a 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_date_time_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_date_time_property.py @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class ModelWithDateTimeProperty: """ datetime_: Union[Unset, datetime.datetime] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: datetime_: Union[Unset, str] = UNSET if not isinstance(self.datetime_, Unset): datetime_ = self.datetime_.isoformat() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if datetime_ is not UNSET: @@ -34,7 +34,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() _datetime_ = d.pop("datetime", UNSET) datetime_: Union[Unset, datetime.datetime] @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_date_time_property @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py index e03a6e698..93a3535db 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_discriminated_union.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -21,13 +21,13 @@ class ModelWithDiscriminatedUnion: """ discriminated_union: Union["ADiscriminatedUnionType1", "ADiscriminatedUnionType2", None, Unset] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 - discriminated_union: Union[Dict[str, Any], None, Unset] + discriminated_union: Union[None, Unset, dict[str, Any]] if isinstance(self.discriminated_union, Unset): discriminated_union = UNSET elif isinstance(self.discriminated_union, ADiscriminatedUnionType1): @@ -37,7 +37,7 @@ def to_dict(self) -> Dict[str, Any]: else: discriminated_union = self.discriminated_union - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if discriminated_union is not UNSET: @@ -46,7 +46,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 @@ -87,7 +87,7 @@ def _parse_discriminated_union( return model_with_discriminated_union @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py index bcf1efa88..765d107d8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties.py @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -28,9 +28,9 @@ class ModelWithMergedProperties: string_to_date: Union[Unset, datetime.date] = UNSET number_to_int: Union[Unset, int] = UNSET any_to_string: Union[Unset, str] = "x" - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: simple_string = self.simple_string string_to_enum: Union[Unset, str] = UNSET @@ -45,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: any_to_string = self.any_to_string - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if simple_string is not UNSET: @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() simple_string = d.pop("simpleString", UNSET) @@ -96,7 +96,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_merged_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_no_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_no_properties.py index 506239f32..24e718e6d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_no_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_no_properties.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define @@ -9,13 +9,13 @@ class ModelWithNoProperties: """ """ - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: model_with_no_properties = cls() return model_with_no_properties diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py index 94afa7653..db13972e9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -22,14 +22,14 @@ class ModelWithPrimitiveAdditionalProperties: """ a_date_holder: Union[Unset, "ModelWithPrimitiveAdditionalPropertiesADateHolder"] = UNSET - additional_properties: Dict[str, str] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - a_date_holder: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + a_date_holder: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.a_date_holder, Unset): a_date_holder = self.a_date_holder.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a_date_holder is not UNSET: @@ -38,7 +38,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_primitive_additional_properties_a_date_holder import ( ModelWithPrimitiveAdditionalPropertiesADateHolder, ) @@ -59,7 +59,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_primitive_additional_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> str: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py index b9920fc60..f53f968ac 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py @@ -1,5 +1,5 @@ import datetime -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,17 +12,17 @@ class ModelWithPrimitiveAdditionalPropertiesADateHolder: """ """ - additional_properties: Dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.isoformat() return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_with_primitive_additional_properties_a_date_holder = cls() @@ -36,7 +36,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_primitive_additional_properties_a_date_holder @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> datetime.datetime: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py index f54afdee8..d8ef017e0 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_property_ref.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,14 +20,14 @@ class ModelWithPropertyRef: """ inner: Union[Unset, "ModelName"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - inner: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + inner: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.inner, Unset): inner = self.inner.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if inner is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_name import ModelName d = src_dict.copy() @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_property_ref @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref.py index 578bca7e0..f7370d6f1 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,14 +16,14 @@ class ModelWithRecursiveRef: """ recursive: Union[Unset, "ModelWithRecursiveRef"] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - recursive: Union[Unset, Dict[str, Any]] = UNSET + def to_dict(self) -> dict[str, Any]: + recursive: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.recursive, Unset): recursive = self.recursive.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if recursive is not UNSET: @@ -32,7 +32,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() _recursive = d.pop("recursive", UNSET) recursive: Union[Unset, ModelWithRecursiveRef] @@ -49,7 +49,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_recursive_ref @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py index 2ed2526f5..961b82697 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,19 +10,19 @@ class ModelWithRecursiveRefInAdditionalProperties: """ """ - additional_properties: Dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = _attrs_field( + additional_properties: dict[str, "ModelWithRecursiveRefInAdditionalProperties"] = _attrs_field( init=False, factory=dict ) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = prop.to_dict() return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() model_with_recursive_ref_in_additional_properties = cls() @@ -36,7 +36,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_recursive_ref_in_additional_properties @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> "ModelWithRecursiveRefInAdditionalProperties": diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py index 890010b78..e818fc69b 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -18,7 +18,7 @@ class ModelWithUnionProperty: a_property: Union[AnEnum, AnIntEnum, Unset] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_property: Union[Unset, int, str] if isinstance(self.a_property, Unset): a_property = UNSET @@ -27,7 +27,7 @@ def to_dict(self) -> Dict[str, Any]: else: a_property = self.a_property.value - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update({}) if a_property is not UNSET: field_dict["a_property"] = a_property @@ -35,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() def _parse_a_property(data: object) -> Union[AnEnum, AnIntEnum, Unset]: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py index 2a832e21a..659496eb6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, Type, TypeVar, Union +from typing import TYPE_CHECKING, Any, TypeVar, Union from attrs import define as _attrs_define @@ -21,10 +21,10 @@ class ModelWithUnionPropertyInlined: fruit: Union["ModelWithUnionPropertyInlinedFruitType0", "ModelWithUnionPropertyInlinedFruitType1", Unset] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 - fruit: Union[Dict[str, Any], Unset] + fruit: Union[Unset, dict[str, Any]] if isinstance(self.fruit, Unset): fruit = UNSET elif isinstance(self.fruit, ModelWithUnionPropertyInlinedFruitType0): @@ -32,7 +32,7 @@ def to_dict(self) -> Dict[str, Any]: else: fruit = self.fruit.to_dict() - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update({}) if fruit is not UNSET: field_dict["fruit"] = fruit @@ -40,7 +40,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.model_with_union_property_inlined_fruit_type_0 import ModelWithUnionPropertyInlinedFruitType0 from ..models.model_with_union_property_inlined_fruit_type_1 import ModelWithUnionPropertyInlinedFruitType1 diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py index b0f25360a..4678b4cef 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_0.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class ModelWithUnionPropertyInlinedFruitType0: """ apples: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: apples = self.apples - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if apples is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() apples = d.pop("apples", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_union_property_inlined_fruit_type_0 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py index 1a32f2445..d70e54234 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property_inlined_fruit_type_1.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class ModelWithUnionPropertyInlinedFruitType1: """ bananas: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: bananas = self.bananas - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if bananas is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() bananas = d.pop("bananas", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return model_with_union_property_inlined_fruit_type_1 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/none.py b/end_to_end_tests/golden-record/my_test_api_client/models/none.py index 3510497bf..23cb7d679 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/none.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/none.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class None_: """ """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() none = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return none @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py index adc78cd6f..ba36efef2 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_data_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class PostBodiesMultipleDataBody: """ a: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a = self.a - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a = d.pop("a", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_bodies_multiple_data_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py index c81dc7636..188abf39e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_files_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class PostBodiesMultipleFilesBody: """ a: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a = self.a - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a is not UNSET: @@ -29,10 +29,10 @@ def to_dict(self) -> Dict[str, Any]: return field_dict - def to_multipart(self) -> Dict[str, Any]: + def to_multipart(self) -> dict[str, Any]: a = self.a if isinstance(self.a, Unset) else (None, str(self.a).encode(), "text/plain") - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = (None, str(prop).encode(), "text/plain") @@ -43,7 +43,7 @@ def to_multipart(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a = d.pop("a", UNSET) @@ -55,7 +55,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_bodies_multiple_files_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py index 88e5ec6f9..f4e7ffaa6 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_bodies_multiple_json_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,12 +16,12 @@ class PostBodiesMultipleJsonBody: """ a: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a = self.a - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if a is not UNSET: @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a = d.pop("a", UNSET) @@ -42,7 +42,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_bodies_multiple_json_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_form_data_inline_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_form_data_inline_body.py index 08a7bbc3a..07c3b2648 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_form_data_inline_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_form_data_inline_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class PostFormDataInlineBody: a_required_field: str an_optional_field: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_required_field = self.a_required_field an_optional_field = self.an_optional_field - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -38,7 +38,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_required_field = d.pop("a_required_field") @@ -53,7 +53,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_form_data_inline_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py index ed2f8efa1..100e84dc9 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class PostNamingPropertyConflictWithImportBody: field: Union[Unset, str] = UNSET define: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: field = self.field define = self.define - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if field is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() field = d.pop("Field", UNSET) @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_naming_property_conflict_with_import_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py index 9bdd79a02..91c550749 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class PostNamingPropertyConflictWithImportResponse200: field: Union[Unset, str] = UNSET define: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: field = self.field define = self.define - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if field is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() field = d.pop("Field", UNSET) @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_naming_property_conflict_with_import_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py index 0b6a29243..9962f552c 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,20 +20,20 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200: """ a: Union["PostResponsesUnionsSimpleBeforeComplexResponse200AType1", str] - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( PostResponsesUnionsSimpleBeforeComplexResponse200AType1, ) - a: Union[Dict[str, Any], str] + a: Union[dict[str, Any], str] if isinstance(self.a, PostResponsesUnionsSimpleBeforeComplexResponse200AType1): a = self.a.to_dict() else: a = self.a - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -44,7 +44,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( PostResponsesUnionsSimpleBeforeComplexResponse200AType1, ) @@ -72,7 +72,7 @@ def _parse_a(data: object) -> Union["PostResponsesUnionsSimpleBeforeComplexRespo return post_responses_unions_simple_before_complex_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py index 601d17cf8..5e8ef0207 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -10,16 +10,16 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200AType1: """ """ - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - field_dict: Dict[str, Any] = {} + def to_dict(self) -> dict[str, Any]: + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() post_responses_unions_simple_before_complex_response_200a_type_1 = cls() @@ -27,7 +27,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_responses_unions_simple_before_complex_response_200a_type_1 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_body.py b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_body.py index 8c1843b41..721011eed 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_body.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -16,10 +16,10 @@ class TestInlineObjectsBody: a_property: Union[Unset, str] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_property = self.a_property - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update({}) if a_property is not UNSET: field_dict["a_property"] = a_property @@ -27,7 +27,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_property = d.pop("a_property", UNSET) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py index 6a0ade77f..2cf353587 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/test_inline_objects_response_200.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -16,10 +16,10 @@ class TestInlineObjectsResponse200: a_property: Union[Unset, str] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_property = self.a_property - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update({}) if a_property is not UNSET: field_dict["a_property"] = a_property @@ -27,7 +27,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_property = d.pop("a_property", UNSET) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py b/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py index 6ff5d4790..112808e62 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/validation_error.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, cast +from typing import Any, TypeVar, cast from attrs import define as _attrs_define @@ -9,46 +9,46 @@ class ValidationError: """ Attributes: - loc (List[str]): + loc (list[str]): msg (str): - type (str): + type_ (str): """ - loc: List[str] + loc: list[str] msg: str - type: str + type_: str - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: loc = self.loc msg = self.msg - type = self.type + type_ = self.type_ - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update( { "loc": loc, "msg": msg, - "type": type, + "type": type_, } ) return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() - loc = cast(List[str], d.pop("loc")) + loc = cast(list[str], d.pop("loc")) msg = d.pop("msg") - type = d.pop("type") + type_ = d.pop("type") validation_error = cls( loc=loc, msg=msg, - type=type, + type_=type_, ) return validation_error diff --git a/end_to_end_tests/golden-record/my_test_api_client/types.py b/end_to_end_tests/golden-record/my_test_api_client/types.py index 21fac106f..fc557103e 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/types.py +++ b/end_to_end_tests/golden-record/my_test_api_client/types.py @@ -1,7 +1,8 @@ """Contains some shared types for properties""" +from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, TypeVar from attrs import define @@ -13,7 +14,7 @@ def __bool__(self) -> Literal[False]: UNSET: Unset = Unset() -FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] @define diff --git a/end_to_end_tests/golden-record/pyproject.toml b/end_to_end_tests/golden-record/pyproject.toml index 526beacf6..d4d3f8766 100644 --- a/end_to_end_tests/golden-record/pyproject.toml +++ b/end_to_end_tests/golden-record/pyproject.toml @@ -11,7 +11,7 @@ include = ["CHANGELOG.md", "my_test_api_client/py.typed"] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" httpx = ">=0.20.0,<0.28.0" attrs = ">=21.3.0" python-dateutil = "^2.8.0" diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py index 851cdf385..52385855c 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/bool_enum_tests_bool_enum_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -11,14 +11,14 @@ def _get_kwargs( *, bool_enum: bool, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} params["bool_enum"] = bool_enum params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/enum/bool", "params": params, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py index 5f9f7f8e5..af4c4ca22 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/enums/int_enum_tests_int_enum_post.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -12,15 +12,15 @@ def _get_kwargs( *, int_enum: AnIntEnum, -) -> Dict[str, Any]: - params: Dict[str, Any] = {} +) -> dict[str, Any]: + params: dict[str, Any] = {} json_int_enum: int = int_enum params["int_enum"] = json_int_enum params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/enum/int", "params": params, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py index ab60a4610..00bc801d9 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/get_user_list.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx @@ -17,20 +17,20 @@ def _get_kwargs( *, - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], int_enum_header: Union[Unset, GetUserListIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetUserListStringEnumHeader] = UNSET, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} if not isinstance(int_enum_header, Unset): headers["Int-Enum-Header"] = str(int_enum_header) if not isinstance(string_enum_header, Unset): headers["String-Enum-Header"] = str(string_enum_header) - params: Dict[str, Any] = {} + params: dict[str, Any] = {} json_an_enum_value = [] for an_enum_value_item_data in an_enum_value: @@ -56,7 +56,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "get", "url": "/tests/", "params": params, @@ -68,7 +68,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -86,7 +86,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -98,20 +98,20 @@ def _build_response( def sync_detailed( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], int_enum_header: Union[Unset, GetUserListIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetUserListStringEnumHeader] = UNSET, -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): int_enum_header (Union[Unset, GetUserListIntEnumHeader]): string_enum_header (Union[Unset, GetUserListStringEnumHeader]): @@ -120,7 +120,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['AModel']] + Response[list['AModel']] """ kwargs = _get_kwargs( @@ -141,20 +141,20 @@ def sync_detailed( def sync( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], int_enum_header: Union[Unset, GetUserListIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetUserListStringEnumHeader] = UNSET, -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): int_enum_header (Union[Unset, GetUserListIntEnumHeader]): string_enum_header (Union[Unset, GetUserListStringEnumHeader]): @@ -163,7 +163,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['AModel'] + list['AModel'] """ return sync_detailed( @@ -179,20 +179,20 @@ def sync( async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], int_enum_header: Union[Unset, GetUserListIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetUserListStringEnumHeader] = UNSET, -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): int_enum_header (Union[Unset, GetUserListIntEnumHeader]): string_enum_header (Union[Unset, GetUserListStringEnumHeader]): @@ -201,7 +201,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['AModel']] + Response[list['AModel']] """ kwargs = _get_kwargs( @@ -220,20 +220,20 @@ async def asyncio_detailed( async def asyncio( *, client: Union[AuthenticatedClient, Client], - an_enum_value: List[AnEnum], - an_enum_value_with_null: List[Union[AnEnumWithNull, None]], - an_enum_value_with_only_null: List[None], + an_enum_value: list[AnEnum], + an_enum_value_with_null: list[Union[AnEnumWithNull, None]], + an_enum_value_with_only_null: list[None], int_enum_header: Union[Unset, GetUserListIntEnumHeader] = UNSET, string_enum_header: Union[Unset, GetUserListStringEnumHeader] = UNSET, -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: """Get List Get a list of things Args: - an_enum_value (List[AnEnum]): - an_enum_value_with_null (List[Union[AnEnumWithNull, None]]): - an_enum_value_with_only_null (List[None]): + an_enum_value (list[AnEnum]): + an_enum_value_with_null (list[Union[AnEnumWithNull, None]]): + an_enum_value_with_only_null (list[None]): int_enum_header (Union[Unset, GetUserListIntEnumHeader]): string_enum_header (Union[Unset, GetUserListStringEnumHeader]): @@ -242,7 +242,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['AModel'] + list['AModel'] """ return ( diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py index 3cbdeddf8..82df1a8f8 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/api/tests/post_user_list.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union import httpx @@ -13,10 +13,10 @@ def _get_kwargs( *, body: PostUserListBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/tests/", } @@ -31,7 +31,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: if response.status_code == 200: response_200 = [] _response_200 = response.json() @@ -49,7 +49,7 @@ def _parse_response( def _build_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: return Response( status_code=HTTPStatus(response.status_code), content=response.content, @@ -62,7 +62,7 @@ def sync_detailed( *, client: Union[AuthenticatedClient, Client], body: PostUserListBody, -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: """Post List Post a list of things @@ -75,7 +75,7 @@ def sync_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['AModel']] + Response[list['AModel']] """ kwargs = _get_kwargs( @@ -93,7 +93,7 @@ def sync( *, client: Union[AuthenticatedClient, Client], body: PostUserListBody, -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: """Post List Post a list of things @@ -106,7 +106,7 @@ def sync( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['AModel'] + list['AModel'] """ return sync_detailed( @@ -119,7 +119,7 @@ async def asyncio_detailed( *, client: Union[AuthenticatedClient, Client], body: PostUserListBody, -) -> Response[List["AModel"]]: +) -> Response[list["AModel"]]: """Post List Post a list of things @@ -132,7 +132,7 @@ async def asyncio_detailed( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - Response[List['AModel']] + Response[list['AModel']] """ kwargs = _get_kwargs( @@ -148,7 +148,7 @@ async def asyncio( *, client: Union[AuthenticatedClient, Client], body: PostUserListBody, -) -> Optional[List["AModel"]]: +) -> Optional[list["AModel"]]: """Post List Post a list of things @@ -161,7 +161,7 @@ async def asyncio( httpx.TimeoutException: If the request takes longer than Client.timeout. Returns: - List['AModel'] + list['AModel'] """ return ( diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py index 0f6d15e84..e80446f10 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx from attrs import define, evolve, field @@ -36,16 +36,16 @@ class Client: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - def with_headers(self, headers: Dict[str, str]) -> "Client": + def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -53,7 +53,7 @@ def with_headers(self, headers: Dict[str, str]) -> "Client": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "Client": + def with_cookies(self, cookies: dict[str, str]) -> "Client": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) @@ -166,12 +166,12 @@ class AuthenticatedClient: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -179,7 +179,7 @@ class AuthenticatedClient: prefix: str = "Bearer" auth_header_name: str = "Authorization" - def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -187,7 +187,7 @@ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py index e05fdaa6d..7050c1a3c 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/a_model.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -19,16 +19,16 @@ class AModel: an_allof_enum_with_overridden_default (AnAllOfEnum): Default: 'overridden_default'. any_value (Union[Unset, Any]): an_optional_allof_enum (Union[Unset, AnAllOfEnum]): - nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]): + nested_list_of_enums (Union[Unset, list[list[DifferentEnum]]]): """ an_enum_value: AnEnum an_allof_enum_with_overridden_default: AnAllOfEnum = "overridden_default" any_value: Union[Unset, Any] = UNSET an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: an_enum_value: str = self.an_enum_value an_allof_enum_with_overridden_default: str = self.an_allof_enum_with_overridden_default @@ -39,7 +39,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.an_optional_allof_enum, Unset): an_optional_allof_enum = self.an_optional_allof_enum - nested_list_of_enums: Union[Unset, List[List[str]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET if not isinstance(self.nested_list_of_enums, Unset): nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: @@ -50,7 +50,7 @@ def to_dict(self) -> Dict[str, Any]: nested_list_of_enums.append(nested_list_of_enums_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update( { "an_enum_value": an_enum_value, @@ -67,7 +67,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() an_enum_value = check_an_enum(d.pop("an_enum_value")) diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py index e238b15a9..3455e04d0 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_all_of_enum.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast AnAllOfEnum = Literal["a_default", "bar", "foo", "overridden_default"] -AN_ALL_OF_ENUM_VALUES: Set[AnAllOfEnum] = { +AN_ALL_OF_ENUM_VALUES: set[AnAllOfEnum] = { "a_default", "bar", "foo", diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum.py index 608b22fc4..27b5c45f9 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast AnEnum = Literal["FIRST_VALUE", "SECOND_VALUE"] -AN_ENUM_VALUES: Set[AnEnum] = { +AN_ENUM_VALUES: set[AnEnum] = { "FIRST_VALUE", "SECOND_VALUE", } diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py index 1519ec27c..4203876de 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_enum_with_null.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast AnEnumWithNull = Literal["FIRST_VALUE", "SECOND_VALUE"] -AN_ENUM_WITH_NULL_VALUES: Set[AnEnumWithNull] = { +AN_ENUM_WITH_NULL_VALUES: set[AnEnumWithNull] = { "FIRST_VALUE", "SECOND_VALUE", } diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py index a3c1108ea..9d0abd942 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/an_int_enum.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast AnIntEnum = Literal[-1, 1, 2] -AN_INT_ENUM_VALUES: Set[AnIntEnum] = { +AN_INT_ENUM_VALUES: set[AnIntEnum] = { -1, 1, 2, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py index d40045c50..e672a9821 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/different_enum.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast DifferentEnum = Literal["DIFFERENT", "OTHER"] -DIFFERENT_ENUM_VALUES: Set[DifferentEnum] = { +DIFFERENT_ENUM_VALUES: set[DifferentEnum] = { "DIFFERENT", "OTHER", } diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py index 50e8114ae..845d6c2a0 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_int_enum_header.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast GetUserListIntEnumHeader = Literal[1, 2, 3] -GET_USER_LIST_INT_ENUM_HEADER_VALUES: Set[GetUserListIntEnumHeader] = { +GET_USER_LIST_INT_ENUM_HEADER_VALUES: set[GetUserListIntEnumHeader] = { 1, 2, 3, diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py index d73cea6a6..55dbbad62 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/get_user_list_string_enum_header.py @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast GetUserListStringEnumHeader = Literal["one", "three", "two"] -GET_USER_LIST_STRING_ENUM_HEADER_VALUES: Set[GetUserListStringEnumHeader] = { +GET_USER_LIST_STRING_ENUM_HEADER_VALUES: set[GetUserListStringEnumHeader] = { "one", "three", "two", diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py index e61cb4183..5566f1b3b 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/models/post_user_list_body.py @@ -1,5 +1,5 @@ import json -from typing import Any, Dict, List, Tuple, Type, TypeVar, Union, cast +from typing import Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -17,31 +17,31 @@ class PostUserListBody: """ Attributes: - an_enum_value (Union[Unset, List[AnEnum]]): - an_enum_value_with_null (Union[Unset, List[Union[AnEnumWithNull, None]]]): - an_enum_value_with_only_null (Union[Unset, List[None]]): + an_enum_value (Union[Unset, list[AnEnum]]): + an_enum_value_with_null (Union[Unset, list[Union[AnEnumWithNull, None]]]): + an_enum_value_with_only_null (Union[Unset, list[None]]): an_allof_enum_with_overridden_default (Union[Unset, AnAllOfEnum]): Default: 'overridden_default'. an_optional_allof_enum (Union[Unset, AnAllOfEnum]): - nested_list_of_enums (Union[Unset, List[List[DifferentEnum]]]): + nested_list_of_enums (Union[Unset, list[list[DifferentEnum]]]): """ - an_enum_value: Union[Unset, List[AnEnum]] = UNSET - an_enum_value_with_null: Union[Unset, List[Union[AnEnumWithNull, None]]] = UNSET - an_enum_value_with_only_null: Union[Unset, List[None]] = UNSET + an_enum_value: Union[Unset, list[AnEnum]] = UNSET + an_enum_value_with_null: Union[Unset, list[Union[AnEnumWithNull, None]]] = UNSET + an_enum_value_with_only_null: Union[Unset, list[None]] = UNSET an_allof_enum_with_overridden_default: Union[Unset, AnAllOfEnum] = "overridden_default" an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET - nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + nested_list_of_enums: Union[Unset, list[list[DifferentEnum]]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - an_enum_value: Union[Unset, List[str]] = UNSET + def to_dict(self) -> dict[str, Any]: + an_enum_value: Union[Unset, list[str]] = UNSET if not isinstance(self.an_enum_value, Unset): an_enum_value = [] for an_enum_value_item_data in self.an_enum_value: an_enum_value_item: str = an_enum_value_item_data an_enum_value.append(an_enum_value_item) - an_enum_value_with_null: Union[Unset, List[Union[None, str]]] = UNSET + an_enum_value_with_null: Union[Unset, list[Union[None, str]]] = UNSET if not isinstance(self.an_enum_value_with_null, Unset): an_enum_value_with_null = [] for an_enum_value_with_null_item_data in self.an_enum_value_with_null: @@ -52,7 +52,7 @@ def to_dict(self) -> Dict[str, Any]: an_enum_value_with_null_item = an_enum_value_with_null_item_data an_enum_value_with_null.append(an_enum_value_with_null_item) - an_enum_value_with_only_null: Union[Unset, List[None]] = UNSET + an_enum_value_with_only_null: Union[Unset, list[None]] = UNSET if not isinstance(self.an_enum_value_with_only_null, Unset): an_enum_value_with_only_null = self.an_enum_value_with_only_null @@ -64,7 +64,7 @@ def to_dict(self) -> Dict[str, Any]: if not isinstance(self.an_optional_allof_enum, Unset): an_optional_allof_enum = self.an_optional_allof_enum - nested_list_of_enums: Union[Unset, List[List[str]]] = UNSET + nested_list_of_enums: Union[Unset, list[list[str]]] = UNSET if not isinstance(self.nested_list_of_enums, Unset): nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: nested_list_of_enums.append(nested_list_of_enums_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if an_enum_value is not UNSET: @@ -93,8 +93,8 @@ def to_dict(self) -> Dict[str, Any]: return field_dict - def to_multipart(self) -> Dict[str, Any]: - an_enum_value: Union[Unset, Tuple[None, bytes, str]] = UNSET + def to_multipart(self) -> dict[str, Any]: + an_enum_value: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.an_enum_value, Unset): _temp_an_enum_value = [] for an_enum_value_item_data in self.an_enum_value: @@ -102,7 +102,7 @@ def to_multipart(self) -> Dict[str, Any]: _temp_an_enum_value.append(an_enum_value_item) an_enum_value = (None, json.dumps(_temp_an_enum_value).encode(), "application/json") - an_enum_value_with_null: Union[Unset, Tuple[None, bytes, str]] = UNSET + an_enum_value_with_null: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.an_enum_value_with_null, Unset): _temp_an_enum_value_with_null = [] for an_enum_value_with_null_item_data in self.an_enum_value_with_null: @@ -114,7 +114,7 @@ def to_multipart(self) -> Dict[str, Any]: _temp_an_enum_value_with_null.append(an_enum_value_with_null_item) an_enum_value_with_null = (None, json.dumps(_temp_an_enum_value_with_null).encode(), "application/json") - an_enum_value_with_only_null: Union[Unset, Tuple[None, bytes, str]] = UNSET + an_enum_value_with_only_null: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.an_enum_value_with_only_null, Unset): _temp_an_enum_value_with_only_null = self.an_enum_value_with_only_null an_enum_value_with_only_null = ( @@ -123,7 +123,7 @@ def to_multipart(self) -> Dict[str, Any]: "application/json", ) - an_allof_enum_with_overridden_default: Union[Unset, Tuple[None, bytes, str]] = UNSET + an_allof_enum_with_overridden_default: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.an_allof_enum_with_overridden_default, Unset): an_allof_enum_with_overridden_default = ( None, @@ -131,11 +131,11 @@ def to_multipart(self) -> Dict[str, Any]: "text/plain", ) - an_optional_allof_enum: Union[Unset, Tuple[None, bytes, str]] = UNSET + an_optional_allof_enum: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.an_optional_allof_enum, Unset): an_optional_allof_enum = (None, str(self.an_optional_allof_enum).encode(), "text/plain") - nested_list_of_enums: Union[Unset, Tuple[None, bytes, str]] = UNSET + nested_list_of_enums: Union[Unset, tuple[None, bytes, str]] = UNSET if not isinstance(self.nested_list_of_enums, Unset): _temp_nested_list_of_enums = [] for nested_list_of_enums_item_data in self.nested_list_of_enums: @@ -147,7 +147,7 @@ def to_multipart(self) -> Dict[str, Any]: _temp_nested_list_of_enums.append(nested_list_of_enums_item) nested_list_of_enums = (None, json.dumps(_temp_nested_list_of_enums).encode(), "application/json") - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = (None, str(prop).encode(), "text/plain") @@ -168,7 +168,7 @@ def to_multipart(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() an_enum_value = [] _an_enum_value = d.pop("an_enum_value", UNSET) @@ -198,7 +198,7 @@ def _parse_an_enum_value_with_null_item(data: object) -> Union[AnEnumWithNull, N an_enum_value_with_null.append(an_enum_value_with_null_item) - an_enum_value_with_only_null = cast(List[None], d.pop("an_enum_value_with_only_null", UNSET)) + an_enum_value_with_only_null = cast(list[None], d.pop("an_enum_value_with_only_null", UNSET)) _an_allof_enum_with_overridden_default = d.pop("an_allof_enum_with_overridden_default", UNSET) an_allof_enum_with_overridden_default: Union[Unset, AnAllOfEnum] @@ -239,7 +239,7 @@ def _parse_an_enum_value_with_null_item(data: object) -> Union[AnEnumWithNull, N return post_user_list_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py index 21fac106f..fc557103e 100644 --- a/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py +++ b/end_to_end_tests/literal-enums-golden-record/my_enum_api_client/types.py @@ -1,7 +1,8 @@ """Contains some shared types for properties""" +from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, TypeVar from attrs import define @@ -13,7 +14,7 @@ def __bool__(self) -> Literal[False]: UNSET: Unset = Unset() -FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] @define diff --git a/end_to_end_tests/literal-enums-golden-record/pyproject.toml b/end_to_end_tests/literal-enums-golden-record/pyproject.toml index d32c2d72c..367eff6ab 100644 --- a/end_to_end_tests/literal-enums-golden-record/pyproject.toml +++ b/end_to_end_tests/literal-enums-golden-record/pyproject.toml @@ -11,7 +11,7 @@ include = ["CHANGELOG.md", "my_enum_api_client/py.typed"] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" httpx = ">=0.20.0,<0.28.0" attrs = ">=21.3.0" python-dateutil = "^2.8.0" diff --git a/end_to_end_tests/metadata_snapshots/pdm.pyproject.toml b/end_to_end_tests/metadata_snapshots/pdm.pyproject.toml index fddcea97f..c33a4cd48 100644 --- a/end_to_end_tests/metadata_snapshots/pdm.pyproject.toml +++ b/end_to_end_tests/metadata_snapshots/pdm.pyproject.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "A client library for accessing Test 3.1 Features" authors = [] readme = "README.md" -requires-python = ">=3.8,<4.0" +requires-python = ">=3.9,<4.0" dependencies = [ "httpx>=0.20.0,<0.28.0", "attrs>=21.3.0", diff --git a/end_to_end_tests/metadata_snapshots/poetry.pyproject.toml b/end_to_end_tests/metadata_snapshots/poetry.pyproject.toml index f9a1becf8..889052b61 100644 --- a/end_to_end_tests/metadata_snapshots/poetry.pyproject.toml +++ b/end_to_end_tests/metadata_snapshots/poetry.pyproject.toml @@ -11,7 +11,7 @@ include = ["CHANGELOG.md", "test_3_1_features_client/py.typed"] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" httpx = ">=0.20.0,<0.28.0" attrs = ">=21.3.0" python-dateutil = "^2.8.0" diff --git a/end_to_end_tests/metadata_snapshots/setup.py b/end_to_end_tests/metadata_snapshots/setup.py index 6350b8c4c..55642b4cd 100644 --- a/end_to_end_tests/metadata_snapshots/setup.py +++ b/end_to_end_tests/metadata_snapshots/setup.py @@ -12,7 +12,7 @@ long_description=long_description, long_description_content_type="text/markdown", packages=find_packages(), - python_requires=">=3.8, <4", + python_requires=">=3.9, <4", install_requires=["httpx >= 0.20.0, < 0.28.0", "attrs >= 21.3.0", "python-dateutil >= 2.8.0, < 3"], package_data={"test_3_1_features_client": ["py.typed"]}, ) diff --git a/end_to_end_tests/test-3-1-golden-record/pyproject.toml b/end_to_end_tests/test-3-1-golden-record/pyproject.toml index f9a1becf8..889052b61 100644 --- a/end_to_end_tests/test-3-1-golden-record/pyproject.toml +++ b/end_to_end_tests/test-3-1-golden-record/pyproject.toml @@ -11,7 +11,7 @@ include = ["CHANGELOG.md", "test_3_1_features_client/py.typed"] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" httpx = ">=0.20.0,<0.28.0" attrs = ">=21.3.0" python-dateutil = "^2.8.0" diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py index 9a8181e26..0d05b8189 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Literal, Optional, Union, cast +from typing import Any, Literal, Optional, Union, cast import httpx @@ -15,10 +15,10 @@ def _get_kwargs( body: PostConstPathBody, required_query: Literal["this always goes in the query"], optional_query: Union[Literal["this sometimes goes in the query"], Unset] = UNSET, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - params: Dict[str, Any] = {} + params: dict[str, Any] = {} params["required query"] = required_query @@ -26,7 +26,7 @@ def _get_kwargs( params = {k: v for k, v in params.items() if v is not UNSET and v is not None} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": f"/const/{path}", "params": params, diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py index 03afbcb0e..f12d53f18 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/prefix_items/post_prefix_items.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -12,10 +12,10 @@ def _get_kwargs( *, body: PostPrefixItemsBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/prefixItems", } diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py index 0f6d15e84..e80446f10 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx from attrs import define, evolve, field @@ -36,16 +36,16 @@ class Client: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - def with_headers(self, headers: Dict[str, str]) -> "Client": + def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -53,7 +53,7 @@ def with_headers(self, headers: Dict[str, str]) -> "Client": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "Client": + def with_cookies(self, cookies: dict[str, str]) -> "Client": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) @@ -166,12 +166,12 @@ class AuthenticatedClient: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -179,7 +179,7 @@ class AuthenticatedClient: prefix: str = "Bearer" auth_header_name: str = "Authorization" - def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -187,7 +187,7 @@ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py index 9ac2f9102..15734903c 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_const_path_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Literal, Type, TypeVar, Union, cast +from typing import Any, Literal, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,9 +20,9 @@ class PostConstPathBody: required: Literal["this always goes in the body"] nullable: Union[Literal["this or null goes in the body"], None] optional: Union[Literal["this sometimes goes in the body"], Unset] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: required = self.required nullable: Union[Literal["this or null goes in the body"], None] @@ -30,7 +30,7 @@ def to_dict(self) -> Dict[str, Any]: optional = self.optional - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -44,7 +44,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() required = cast(Literal["this always goes in the body"], d.pop("required")) if required != "this always goes in the body": @@ -77,7 +77,7 @@ def _parse_nullable(data: object) -> Union[Literal["this or null goes in the bod return post_const_path_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py index f3edd841d..a578b3091 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/models/post_prefix_items_body.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Literal, Type, TypeVar, Union, cast +from typing import Any, Literal, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -12,16 +12,16 @@ class PostPrefixItemsBody: """ Attributes: - prefix_items_and_items (Union[Unset, List[Union[Literal['prefix'], float, str]]]): - prefix_items_only (Union[Unset, List[Union[float, str]]]): + prefix_items_and_items (Union[Unset, list[Union[Literal['prefix'], float, str]]]): + prefix_items_only (Union[Unset, list[Union[float, str]]]): """ - prefix_items_and_items: Union[Unset, List[Union[Literal["prefix"], float, str]]] = UNSET - prefix_items_only: Union[Unset, List[Union[float, str]]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + prefix_items_and_items: Union[Unset, list[Union[Literal["prefix"], float, str]]] = UNSET + prefix_items_only: Union[Unset, list[Union[float, str]]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - prefix_items_and_items: Union[Unset, List[Union[Literal["prefix"], float, str]]] = UNSET + def to_dict(self) -> dict[str, Any]: + prefix_items_and_items: Union[Unset, list[Union[Literal["prefix"], float, str]]] = UNSET if not isinstance(self.prefix_items_and_items, Unset): prefix_items_and_items = [] for prefix_items_and_items_item_data in self.prefix_items_and_items: @@ -29,7 +29,7 @@ def to_dict(self) -> Dict[str, Any]: prefix_items_and_items_item = prefix_items_and_items_item_data prefix_items_and_items.append(prefix_items_and_items_item) - prefix_items_only: Union[Unset, List[Union[float, str]]] = UNSET + prefix_items_only: Union[Unset, list[Union[float, str]]] = UNSET if not isinstance(self.prefix_items_only, Unset): prefix_items_only = [] for prefix_items_only_item_data in self.prefix_items_only: @@ -37,7 +37,7 @@ def to_dict(self) -> Dict[str, Any]: prefix_items_only_item = prefix_items_only_item_data prefix_items_only.append(prefix_items_only_item) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if prefix_items_and_items is not UNSET: @@ -48,7 +48,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() prefix_items_and_items = [] _prefix_items_and_items = d.pop("prefixItemsAndItems", UNSET) @@ -87,7 +87,7 @@ def _parse_prefix_items_only_item(data: object) -> Union[float, str]: return post_prefix_items_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py index 21fac106f..fc557103e 100644 --- a/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py +++ b/end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/types.py @@ -1,7 +1,8 @@ """Contains some shared types for properties""" +from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, TypeVar from attrs import define @@ -13,7 +14,7 @@ def __bool__(self) -> Literal[False]: UNSET: Unset = Unset() -FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] @define diff --git a/end_to_end_tests/test_custom_templates/api_init.py.jinja b/end_to_end_tests/test_custom_templates/api_init.py.jinja index 0c5720bf2..78e473147 100644 --- a/end_to_end_tests/test_custom_templates/api_init.py.jinja +++ b/end_to_end_tests/test_custom_templates/api_init.py.jinja @@ -1,6 +1,5 @@ """ Contains methods for accessing the API """ -from typing import Type {% for tag in endpoint_collections_by_tag.keys() %} from .{{ tag }} import {{ class_name(tag) }}Endpoints {% endfor %} @@ -8,6 +7,6 @@ from .{{ tag }} import {{ class_name(tag) }}Endpoints class {{ class_name(package_name) }}Api: {% for tag in endpoint_collections_by_tag.keys() %} @classmethod - def {{ tag }}(cls) -> Type[{{ class_name(tag) }}Endpoints]: + def {{ tag }}(cls) -> type[{{ class_name(tag) }}Endpoints]: return {{ class_name(tag) }}Endpoints {% endfor %} diff --git a/end_to_end_tests/test_end_to_end.py b/end_to_end_tests/test_end_to_end.py index a448a0698..2452c3acd 100644 --- a/end_to_end_tests/test_end_to_end.py +++ b/end_to_end_tests/test_end_to_end.py @@ -1,7 +1,7 @@ import shutil from filecmp import cmpfiles, dircmp from pathlib import Path -from typing import Dict, List, Optional, Set +from typing import Optional import pytest from click.testing import Result @@ -13,9 +13,9 @@ def _compare_directories( record: Path, test_subject: Path, - expected_differences: Dict[Path, str], - expected_missing: Optional[Set[str]] = None, - ignore: List[str] = None, + expected_differences: dict[Path, str], + expected_missing: Optional[set[str]] = None, + ignore: list[str] = None, depth=0, ): """ @@ -78,11 +78,11 @@ def _compare_directories( def run_e2e_test( openapi_document: str, - extra_args: List[str], - expected_differences: Optional[Dict[Path, str]] = None, + extra_args: list[str], + expected_differences: Optional[dict[Path, str]] = None, golden_record_path: str = "golden-record", output_path: str = "my-test-api-client", - expected_missing: Optional[Set[str]] = None, + expected_missing: Optional[set[str]] = None, ) -> Result: output_path = Path.cwd() / output_path shutil.rmtree(output_path, ignore_errors=True) @@ -107,12 +107,12 @@ def run_e2e_test( return result -def generate(extra_args: Optional[List[str]], openapi_document: str) -> Result: +def generate(extra_args: Optional[list[str]], openapi_document: str) -> Result: """Generate a client from an OpenAPI document and return the path to the generated code""" _run_command("generate", extra_args, openapi_document) -def _run_command(command: str, extra_args: Optional[List[str]] = None, openapi_document: Optional[str] = None, url: Optional[str] = None, config_path: Optional[Path] = None) -> Result: +def _run_command(command: str, extra_args: Optional[list[str]] = None, openapi_document: Optional[str] = None, url: Optional[str] = None, config_path: Optional[Path] = None) -> Result: """Generate a client from an OpenAPI document and return the path to the generated code""" runner = CliRunner() if openapi_document is not None: diff --git a/integration-tests/integration_tests/api/body/post_body_multipart.py b/integration-tests/integration_tests/api/body/post_body_multipart.py index bfef23f2e..13c943ad7 100644 --- a/integration-tests/integration_tests/api/body/post_body_multipart.py +++ b/integration-tests/integration_tests/api/body/post_body_multipart.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -14,10 +14,10 @@ def _get_kwargs( *, body: PostBodyMultipartBody, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/body/multipart", } diff --git a/integration-tests/integration_tests/api/parameters/post_parameters_header.py b/integration-tests/integration_tests/api/parameters/post_parameters_header.py index 90858f9bb..0981585cc 100644 --- a/integration-tests/integration_tests/api/parameters/post_parameters_header.py +++ b/integration-tests/integration_tests/api/parameters/post_parameters_header.py @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx @@ -16,8 +16,8 @@ def _get_kwargs( string_header: str, number_header: float, integer_header: int, -) -> Dict[str, Any]: - headers: Dict[str, Any] = {} +) -> dict[str, Any]: + headers: dict[str, Any] = {} headers["Boolean-Header"] = "true" if boolean_header else "false" headers["String-Header"] = string_header @@ -26,7 +26,7 @@ def _get_kwargs( headers["Integer-Header"] = str(integer_header) - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "post", "url": "/parameters/header", } diff --git a/integration-tests/integration_tests/client.py b/integration-tests/integration_tests/client.py index 0f6d15e84..e80446f10 100644 --- a/integration-tests/integration_tests/client.py +++ b/integration-tests/integration_tests/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union import httpx from attrs import define, evolve, field @@ -36,16 +36,16 @@ class Client: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) - def with_headers(self, headers: Dict[str, str]) -> "Client": + def with_headers(self, headers: dict[str, str]) -> "Client": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -53,7 +53,7 @@ def with_headers(self, headers: Dict[str, str]) -> "Client": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "Client": + def with_cookies(self, cookies: dict[str, str]) -> "Client": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) @@ -166,12 +166,12 @@ class AuthenticatedClient: raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) @@ -179,7 +179,7 @@ class AuthenticatedClient: prefix: str = "Bearer" auth_header_name: str = "Authorization" - def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -187,7 +187,7 @@ def with_headers(self, headers: Dict[str, str]) -> "AuthenticatedClient": self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "AuthenticatedClient": + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/integration-tests/integration_tests/models/post_body_multipart_body.py b/integration-tests/integration_tests/models/post_body_multipart_body.py index f0272a34e..13174200d 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_body.py +++ b/integration-tests/integration_tests/models/post_body_multipart_body.py @@ -1,5 +1,5 @@ from io import BytesIO -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -22,16 +22,16 @@ class PostBodyMultipartBody: a_string: str file: File description: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_string = self.a_string file = self.file.to_tuple() description = self.description - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -44,7 +44,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict - def to_multipart(self) -> Dict[str, Any]: + def to_multipart(self) -> dict[str, Any]: a_string = (None, str(self.a_string).encode(), "text/plain") file = self.file.to_tuple() @@ -55,7 +55,7 @@ def to_multipart(self) -> Dict[str, Any]: else (None, str(self.description).encode(), "text/plain") ) - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} for prop_name, prop in self.additional_properties.items(): field_dict[prop_name] = (None, str(prop).encode(), "text/plain") @@ -71,7 +71,7 @@ def to_multipart(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_string = d.pop("a_string") @@ -89,7 +89,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_body_multipart_body @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/integration-tests/integration_tests/models/post_body_multipart_response_200.py b/integration-tests/integration_tests/models/post_body_multipart_response_200.py index 79359ec41..65f38c082 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_response_200.py +++ b/integration-tests/integration_tests/models/post_body_multipart_response_200.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -22,9 +22,9 @@ class PostBodyMultipartResponse200: description: str file_name: str file_content_type: str - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: a_string = self.a_string file_data = self.file_data @@ -35,7 +35,7 @@ def to_dict(self) -> Dict[str, Any]: file_content_type = self.file_content_type - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -50,7 +50,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() a_string = d.pop("a_string") @@ -74,7 +74,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_body_multipart_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/integration-tests/integration_tests/models/post_parameters_header_response_200.py b/integration-tests/integration_tests/models/post_parameters_header_response_200.py index 03e688ba1..ff44f5644 100644 --- a/integration-tests/integration_tests/models/post_parameters_header_response_200.py +++ b/integration-tests/integration_tests/models/post_parameters_header_response_200.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar +from typing import Any, TypeVar from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -20,9 +20,9 @@ class PostParametersHeaderResponse200: string: str number: float integer: int - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: boolean = self.boolean string = self.string @@ -31,7 +31,7 @@ def to_dict(self) -> Dict[str, Any]: integer = self.integer - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { @@ -45,7 +45,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() boolean = d.pop("boolean") @@ -66,7 +66,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return post_parameters_header_response_200 @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/integration-tests/integration_tests/models/problem.py b/integration-tests/integration_tests/models/problem.py index bde5b6d37..f61f42b5d 100644 --- a/integration-tests/integration_tests/models/problem.py +++ b/integration-tests/integration_tests/models/problem.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Type, TypeVar, Union +from typing import Any, TypeVar, Union from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -18,14 +18,14 @@ class Problem: parameter_name: Union[Unset, str] = UNSET description: Union[Unset, str] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: parameter_name = self.parameter_name description = self.description - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if parameter_name is not UNSET: @@ -36,7 +36,7 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: d = src_dict.copy() parameter_name = d.pop("parameter_name", UNSET) @@ -51,7 +51,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return problem @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/integration-tests/integration_tests/models/public_error.py b/integration-tests/integration_tests/models/public_error.py index 993bd8ad3..5e9d53c26 100644 --- a/integration-tests/integration_tests/models/public_error.py +++ b/integration-tests/integration_tests/models/public_error.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast +from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -16,39 +16,39 @@ class PublicError: """ Attributes: - errors (Union[Unset, List[str]]): - extra_parameters (Union[Unset, List[str]]): - invalid_parameters (Union[Unset, List['Problem']]): - missing_parameters (Union[Unset, List[str]]): + errors (Union[Unset, list[str]]): + extra_parameters (Union[Unset, list[str]]): + invalid_parameters (Union[Unset, list['Problem']]): + missing_parameters (Union[Unset, list[str]]): """ - errors: Union[Unset, List[str]] = UNSET - extra_parameters: Union[Unset, List[str]] = UNSET - invalid_parameters: Union[Unset, List["Problem"]] = UNSET - missing_parameters: Union[Unset, List[str]] = UNSET - additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) + errors: Union[Unset, list[str]] = UNSET + extra_parameters: Union[Unset, list[str]] = UNSET + invalid_parameters: Union[Unset, list["Problem"]] = UNSET + missing_parameters: Union[Unset, list[str]] = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) - def to_dict(self) -> Dict[str, Any]: - errors: Union[Unset, List[str]] = UNSET + def to_dict(self) -> dict[str, Any]: + errors: Union[Unset, list[str]] = UNSET if not isinstance(self.errors, Unset): errors = self.errors - extra_parameters: Union[Unset, List[str]] = UNSET + extra_parameters: Union[Unset, list[str]] = UNSET if not isinstance(self.extra_parameters, Unset): extra_parameters = self.extra_parameters - invalid_parameters: Union[Unset, List[Dict[str, Any]]] = UNSET + invalid_parameters: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.invalid_parameters, Unset): invalid_parameters = [] for invalid_parameters_item_data in self.invalid_parameters: invalid_parameters_item = invalid_parameters_item_data.to_dict() invalid_parameters.append(invalid_parameters_item) - missing_parameters: Union[Unset, List[str]] = UNSET + missing_parameters: Union[Unset, list[str]] = UNSET if not isinstance(self.missing_parameters, Unset): missing_parameters = self.missing_parameters - field_dict: Dict[str, Any] = {} + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if errors is not UNSET: @@ -63,13 +63,13 @@ def to_dict(self) -> Dict[str, Any]: return field_dict @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: from ..models.problem import Problem d = src_dict.copy() - errors = cast(List[str], d.pop("errors", UNSET)) + errors = cast(list[str], d.pop("errors", UNSET)) - extra_parameters = cast(List[str], d.pop("extra_parameters", UNSET)) + extra_parameters = cast(list[str], d.pop("extra_parameters", UNSET)) invalid_parameters = [] _invalid_parameters = d.pop("invalid_parameters", UNSET) @@ -78,7 +78,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: invalid_parameters.append(invalid_parameters_item) - missing_parameters = cast(List[str], d.pop("missing_parameters", UNSET)) + missing_parameters = cast(list[str], d.pop("missing_parameters", UNSET)) public_error = cls( errors=errors, @@ -91,7 +91,7 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: return public_error @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: diff --git a/integration-tests/integration_tests/types.py b/integration-tests/integration_tests/types.py index 21fac106f..fc557103e 100644 --- a/integration-tests/integration_tests/types.py +++ b/integration-tests/integration_tests/types.py @@ -1,7 +1,8 @@ """Contains some shared types for properties""" +from collections.abc import MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, MutableMapping, Optional, Tuple, TypeVar +from typing import BinaryIO, Generic, Literal, Optional, TypeVar from attrs import define @@ -13,7 +14,7 @@ def __bool__(self) -> Literal[False]: UNSET: Unset = Unset() -FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] @define diff --git a/openapi_python_client/__init__.py b/openapi_python_client/__init__.py index f2cfb40ec..2225d2008 100644 --- a/openapi_python_client/__init__.py +++ b/openapi_python_client/__init__.py @@ -4,10 +4,11 @@ import mimetypes import shutil import subprocess +from collections.abc import Sequence from importlib.metadata import version from pathlib import Path from subprocess import CalledProcessError -from typing import Any, Dict, List, Optional, Sequence, Union +from typing import Any, Optional, Union import httpcore import httpx @@ -101,7 +102,7 @@ def __init__( openapi=self.openapi, endpoint_collections_by_tag=self.openapi.endpoint_collections_by_tag, ) - self.errors: List[GeneratorError] = [] + self.errors: list[GeneratorError] = [] def build(self) -> Sequence[GeneratorError]: """Create the project from templates""" @@ -147,8 +148,8 @@ def _run_command(self, cmd: str) -> None: ) ) - def _get_errors(self) -> List[GeneratorError]: - errors: List[GeneratorError] = [] + def _get_errors(self) -> list[GeneratorError]: + errors: list[GeneratorError] = [] for collection in self.openapi.endpoint_collections_by_tag.values(): errors.extend(collection.parse_errors) errors.extend(self.openapi.errors) @@ -325,7 +326,7 @@ def generate( return project.build() -def _load_yaml_or_json(data: bytes, content_type: Optional[str]) -> Union[Dict[str, Any], GeneratorError]: +def _load_yaml_or_json(data: bytes, content_type: Optional[str]) -> Union[dict[str, Any], GeneratorError]: if content_type == "application/json": try: return json.loads(data.decode()) @@ -339,7 +340,7 @@ def _load_yaml_or_json(data: bytes, content_type: Optional[str]) -> Union[Dict[s return GeneratorError(header=f"Invalid YAML from provided source: {err}") -def _get_document(*, source: Union[str, Path], timeout: int) -> Union[Dict[str, Any], GeneratorError]: +def _get_document(*, source: Union[str, Path], timeout: int) -> Union[dict[str, Any], GeneratorError]: yaml_bytes: bytes content_type: Optional[str] if isinstance(source, str): diff --git a/openapi_python_client/cli.py b/openapi_python_client/cli.py index e8fd50f9e..20c8c9d0a 100644 --- a/openapi_python_client/cli.py +++ b/openapi_python_client/cli.py @@ -1,7 +1,8 @@ import codecs +from collections.abc import Sequence from pathlib import Path from pprint import pformat -from typing import Optional, Sequence, Union +from typing import Optional, Union import typer diff --git a/openapi_python_client/config.py b/openapi_python_client/config.py index 6625bda1f..c7f5d8ad9 100644 --- a/openapi_python_client/config.py +++ b/openapi_python_client/config.py @@ -2,7 +2,7 @@ import mimetypes from enum import Enum from pathlib import Path -from typing import Dict, List, Optional, Union +from typing import Optional, Union from attr import define from pydantic import BaseModel @@ -34,13 +34,13 @@ class ConfigFile(BaseModel): See https://github.com/openapi-generators/openapi-python-client#configuration """ - class_overrides: Optional[Dict[str, ClassOverride]] = None - content_type_overrides: Optional[Dict[str, str]] = None + class_overrides: Optional[dict[str, ClassOverride]] = None + content_type_overrides: Optional[dict[str, str]] = None project_name_override: Optional[str] = None package_name_override: Optional[str] = None package_version_override: Optional[str] = None use_path_prefixes_for_title_model_names: bool = True - post_hooks: Optional[List[str]] = None + post_hooks: Optional[list[str]] = None field_prefix: str = "field_" http_timeout: int = 5 literal_enums: bool = False @@ -63,18 +63,18 @@ class Config: """Contains all the config values for the generator, from files, defaults, and CLI arguments.""" meta_type: MetaType - class_overrides: Dict[str, ClassOverride] + class_overrides: dict[str, ClassOverride] project_name_override: Optional[str] package_name_override: Optional[str] package_version_override: Optional[str] use_path_prefixes_for_title_model_names: bool - post_hooks: List[str] + post_hooks: list[str] field_prefix: str http_timeout: int literal_enums: bool document_source: Union[Path, str] file_encoding: str - content_type_overrides: Dict[str, str] + content_type_overrides: dict[str, str] overwrite: bool output_path: Optional[Path] diff --git a/openapi_python_client/parser/bodies.py b/openapi_python_client/parser/bodies.py index 8515ad7cc..c51966412 100644 --- a/openapi_python_client/parser/bodies.py +++ b/openapi_python_client/parser/bodies.py @@ -1,5 +1,5 @@ import sys -from typing import Dict, List, Tuple, Union +from typing import Union import attr @@ -44,10 +44,10 @@ def body_from_data( *, data: oai.Operation, schemas: Schemas, - request_bodies: Dict[str, Union[oai.RequestBody, oai.Reference]], + request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]], config: Config, endpoint_name: str, -) -> Tuple[List[Union[Body, ParseError]], Schemas]: +) -> tuple[list[Union[Body, ParseError]], Schemas]: """Adds form or JSON body to Endpoint if included in data""" body = _resolve_reference(data.request_body, request_bodies) if isinstance(body, ParseError): @@ -55,7 +55,7 @@ def body_from_data( if body is None: return [], schemas - bodies: List[Union[Body, ParseError]] = [] + bodies: list[Union[Body, ParseError]] = [] body_content = body.content prefix_type_names = len(body_content) > 1 @@ -131,7 +131,7 @@ def body_from_data( def _resolve_reference( - body: Union[oai.RequestBody, oai.Reference, None], request_bodies: Dict[str, Union[oai.RequestBody, oai.Reference]] + body: Union[oai.RequestBody, oai.Reference, None], request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]] ) -> Union[oai.RequestBody, ParseError, None]: if body is None: return None diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index acc8998cd..43e63c434 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -1,8 +1,9 @@ import re +from collections.abc import Iterator from copy import deepcopy from dataclasses import dataclass, field from http import HTTPStatus -from typing import Any, Dict, Iterator, List, Optional, Protocol, Set, Tuple, Union +from typing import Any, Optional, Protocol, Union from pydantic import ValidationError @@ -40,20 +41,20 @@ class EndpointCollection: """A bunch of endpoints grouped under a tag that will become a module""" tag: str - endpoints: List["Endpoint"] = field(default_factory=list) - parse_errors: List[ParseError] = field(default_factory=list) + endpoints: list["Endpoint"] = field(default_factory=list) + parse_errors: list[ParseError] = field(default_factory=list) @staticmethod def from_data( *, - data: Dict[str, oai.PathItem], + data: dict[str, oai.PathItem], schemas: Schemas, parameters: Parameters, - request_bodies: Dict[str, Union[oai.RequestBody, oai.Reference]], + request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]], config: Config, - ) -> Tuple[Dict[utils.PythonIdentifier, "EndpointCollection"], Schemas, Parameters]: + ) -> tuple[dict[utils.PythonIdentifier, "EndpointCollection"], Schemas, Parameters]: """Parse the openapi paths data to get EndpointCollections by tag""" - endpoints_by_tag: Dict[utils.PythonIdentifier, EndpointCollection] = {} + endpoints_by_tag: dict[utils.PythonIdentifier, EndpointCollection] = {} methods = ["get", "put", "post", "delete", "options", "head", "patch", "trace"] @@ -117,7 +118,7 @@ class RequestBodyParser(Protocol): def __call__( self, *, body: oai.RequestBody, schemas: Schemas, parent_name: str, config: Config - ) -> Tuple[Union[Property, PropertyError, None], Schemas]: ... # pragma: no cover + ) -> tuple[Union[Property, PropertyError, None], Schemas]: ... # pragma: no cover @dataclass @@ -133,19 +134,19 @@ class Endpoint: requires_security: bool tag: str summary: Optional[str] = "" - relative_imports: Set[str] = field(default_factory=set) - query_parameters: List[Property] = field(default_factory=list) - path_parameters: List[Property] = field(default_factory=list) - header_parameters: List[Property] = field(default_factory=list) - cookie_parameters: List[Property] = field(default_factory=list) - responses: List[Response] = field(default_factory=list) - bodies: List[Body] = field(default_factory=list) - errors: List[ParseError] = field(default_factory=list) + relative_imports: set[str] = field(default_factory=set) + query_parameters: list[Property] = field(default_factory=list) + path_parameters: list[Property] = field(default_factory=list) + header_parameters: list[Property] = field(default_factory=list) + cookie_parameters: list[Property] = field(default_factory=list) + responses: list[Response] = field(default_factory=list) + bodies: list[Body] = field(default_factory=list) + errors: list[ParseError] = field(default_factory=list) @staticmethod def _add_responses( *, endpoint: "Endpoint", data: oai.Responses, schemas: Schemas, config: Config - ) -> Tuple["Endpoint", Schemas]: + ) -> tuple["Endpoint", Schemas]: endpoint = deepcopy(endpoint) for code, response_data in data.items(): status_code: HTTPStatus @@ -197,7 +198,7 @@ def add_parameters( schemas: Schemas, parameters: Parameters, config: Config, - ) -> Tuple[Union["Endpoint", ParseError], Schemas, Parameters]: + ) -> tuple[Union["Endpoint", ParseError], Schemas, Parameters]: """Process the defined `parameters` for an Endpoint. Any existing parameters will be ignored, so earlier instances of a parameter take precedence. PathItem @@ -226,8 +227,8 @@ def add_parameters( endpoint = deepcopy(endpoint) - unique_parameters: Set[Tuple[str, oai.ParameterLocation]] = set() - parameters_by_location: Dict[str, List[Property]] = { + unique_parameters: set[tuple[str, oai.ParameterLocation]] = set() + parameters_by_location: dict[str, list[Property]] = { oai.ParameterLocation.QUERY: endpoint.query_parameters, oai.ParameterLocation.PATH: endpoint.path_parameters, oai.ParameterLocation.HEADER: endpoint.header_parameters, @@ -304,7 +305,7 @@ def _check_parameters_for_conflicts( self, *, config: Config, - previously_modified_params: Optional[Set[Tuple[oai.ParameterLocation, str]]] = None, + previously_modified_params: Optional[set[tuple[oai.ParameterLocation, str]]] = None, ) -> Union["Endpoint", ParseError]: """Check for conflicting parameters @@ -316,7 +317,7 @@ def _check_parameters_for_conflicts( unique python_name. """ modified_params = previously_modified_params or set() - used_python_names: Dict[PythonIdentifier, Tuple[oai.ParameterLocation, Property]] = {} + used_python_names: dict[PythonIdentifier, tuple[oai.ParameterLocation, Property]] = {} reserved_names = ["client", "url"] for parameter in self.iter_all_parameters(): location, prop = parameter @@ -395,9 +396,9 @@ def from_data( tag: str, schemas: Schemas, parameters: Parameters, - request_bodies: Dict[str, Union[oai.RequestBody, oai.Reference]], + request_bodies: dict[str, Union[oai.RequestBody, oai.Reference]], config: Config, - ) -> Tuple[Union["Endpoint", ParseError], Schemas, Parameters]: + ) -> tuple[Union["Endpoint", ParseError], Schemas, Parameters]: """Construct an endpoint from the OpenAPI data""" if data.operationId is None: @@ -461,15 +462,15 @@ def response_type(self) -> str: return self.responses[0].prop.get_type_string(quoted=False) return f"Union[{', '.join(types)}]" - def iter_all_parameters(self) -> Iterator[Tuple[oai.ParameterLocation, Property]]: + def iter_all_parameters(self) -> Iterator[tuple[oai.ParameterLocation, Property]]: """Iterate through all the parameters of this endpoint""" yield from ((oai.ParameterLocation.PATH, param) for param in self.path_parameters) yield from ((oai.ParameterLocation.QUERY, param) for param in self.query_parameters) yield from ((oai.ParameterLocation.HEADER, param) for param in self.header_parameters) yield from ((oai.ParameterLocation.COOKIE, param) for param in self.cookie_parameters) - def list_all_parameters(self) -> List[Property]: - """Return a List of all the parameters of this endpoint""" + def list_all_parameters(self) -> list[Property]: + """Return a list of all the parameters of this endpoint""" return ( self.path_parameters + self.query_parameters @@ -487,12 +488,12 @@ class GeneratorData: description: Optional[str] version: str models: Iterator[ModelProperty] - errors: List[ParseError] - endpoint_collections_by_tag: Dict[utils.PythonIdentifier, EndpointCollection] + errors: list[ParseError] + endpoint_collections_by_tag: dict[utils.PythonIdentifier, EndpointCollection] enums: Iterator[Union[EnumProperty, LiteralEnumProperty]] @staticmethod - def from_dict(data: Dict[str, Any], *, config: Config) -> Union["GeneratorData", GeneratorError]: + def from_dict(data: dict[str, Any], *, config: Config) -> Union["GeneratorData", GeneratorError]: """Create an OpenAPI from dict""" try: openapi = oai.OpenAPI.model_validate(data) diff --git a/openapi_python_client/parser/properties/__init__.py b/openapi_python_client/parser/properties/__init__.py index 94c6e3d08..e202d9cf5 100644 --- a/openapi_python_client/parser/properties/__init__.py +++ b/openapi_python_client/parser/properties/__init__.py @@ -14,7 +14,7 @@ "property_from_data", ] -from typing import Iterable +from collections.abc import Iterable from attrs import evolve diff --git a/openapi_python_client/parser/properties/enum_property.py b/openapi_python_client/parser/properties/enum_property.py index 29609864f..fc7f20bd9 100644 --- a/openapi_python_client/parser/properties/enum_property.py +++ b/openapi_python_client/parser/properties/enum_property.py @@ -2,7 +2,7 @@ __all__ = ["EnumProperty", "ValueType"] -from typing import Any, ClassVar, List, Union, cast +from typing import Any, ClassVar, Union, cast from attr import evolve from attrs import define @@ -99,7 +99,7 @@ def build( # noqa: PLR0911 if value_type not in (str, int): return PropertyError(header=f"Unsupported enum type {value_type}", data=data), schemas value_list = cast( - Union[List[int], List[str]], unchecked_value_list + Union[list[int], list[str]], unchecked_value_list ) # We checked this with all the value_types stuff if len(value_list) < len(enum): # Only one of the values was None, that becomes a union diff --git a/openapi_python_client/parser/properties/list_property.py b/openapi_python_client/parser/properties/list_property.py index 47a52cda3..bf0756fe3 100644 --- a/openapi_python_client/parser/properties/list_property.py +++ b/openapi_python_client/parser/properties/list_property.py @@ -106,10 +106,10 @@ def convert_value(self, value: Any) -> Value | None | PropertyError: return None # pragma: no cover def get_base_type_string(self, *, quoted: bool = False) -> str: - return f"List[{self.inner_property.get_type_string(quoted=not self.inner_property.is_base_type)}]" + return f"list[{self.inner_property.get_type_string(quoted=not self.inner_property.is_base_type)}]" def get_base_json_type_string(self, *, quoted: bool = False) -> str: - return f"List[{self.inner_property.get_type_string(json=True, quoted=not self.inner_property.is_base_type)}]" + return f"list[{self.inner_property.get_type_string(json=True, quoted=not self.inner_property.is_base_type)}]" def get_instance_type_string(self) -> str: """Get a string representation of runtime type that should be used for `isinstance` checks""" @@ -125,7 +125,7 @@ def get_imports(self, *, prefix: str) -> set[str]: """ imports = super().get_imports(prefix=prefix) imports.update(self.inner_property.get_imports(prefix=prefix)) - imports.add("from typing import cast, List") + imports.add("from typing import cast") return imports def get_lazy_imports(self, *, prefix: str) -> set[str]: @@ -151,7 +151,7 @@ def get_type_string( if json: type_string = self.get_base_json_type_string() elif multipart: - type_string = "Tuple[None, bytes, str]" + type_string = "tuple[None, bytes, str]" else: type_string = self.get_base_type_string() diff --git a/openapi_python_client/parser/properties/literal_enum_property.py b/openapi_python_client/parser/properties/literal_enum_property.py index c305a9a41..669b62f58 100644 --- a/openapi_python_client/parser/properties/literal_enum_property.py +++ b/openapi_python_client/parser/properties/literal_enum_property.py @@ -2,7 +2,7 @@ __all__ = ["LiteralEnumProperty"] -from typing import Any, ClassVar, List, Union, cast +from typing import Any, ClassVar, Union, cast from attr import evolve from attrs import define @@ -98,7 +98,7 @@ def build( # noqa: PLR0911 if value_type not in (str, int): return PropertyError(header=f"Unsupported enum type {value_type}", data=data), schemas value_list = cast( - Union[List[int], List[str]], unchecked_value_list + Union[list[int], list[str]], unchecked_value_list ) # We checked this with all the value_types stuff if len(value_list) < len(enum): # Only one of the values was None, that becomes a union diff --git a/openapi_python_client/parser/properties/model_property.py b/openapi_python_client/parser/properties/model_property.py index 0dc13be54..762624501 100644 --- a/openapi_python_client/parser/properties/model_property.py +++ b/openapi_python_client/parser/properties/model_property.py @@ -32,7 +32,7 @@ class ModelProperty(PropertyProtocol): relative_imports: set[str] | None lazy_imports: set[str] | None additional_properties: Property | None - _json_type_string: ClassVar[str] = "Dict[str, Any]" + _json_type_string: ClassVar[str] = "dict[str, Any]" template: ClassVar[str] = "model_property.py.jinja" json_is_dict: ClassVar[bool] = True @@ -154,7 +154,6 @@ def get_imports(self, *, prefix: str) -> set[str]: imports = super().get_imports(prefix=prefix) imports.update( { - "from typing import Dict", "from typing import cast", } ) @@ -203,7 +202,7 @@ def get_type_string( if json: type_string = self.get_base_json_type_string() elif multipart: - type_string = "Tuple[None, bytes, str]" + type_string = "tuple[None, bytes, str]" else: type_string = self.get_base_type_string() diff --git a/openapi_python_client/parser/properties/protocol.py b/openapi_python_client/parser/properties/protocol.py index c9555949d..9a5b51828 100644 --- a/openapi_python_client/parser/properties/protocol.py +++ b/openapi_python_client/parser/properties/protocol.py @@ -116,7 +116,7 @@ def get_type_string( if json: type_string = self.get_base_json_type_string(quoted=quoted) elif multipart: - type_string = "Tuple[None, bytes, str]" + type_string = "tuple[None, bytes, str]" else: type_string = self.get_base_type_string(quoted=quoted) diff --git a/openapi_python_client/parser/properties/schemas.py b/openapi_python_client/parser/properties/schemas.py index dad89a572..ce0b3d35d 100644 --- a/openapi_python_client/parser/properties/schemas.py +++ b/openapi_python_client/parser/properties/schemas.py @@ -10,7 +10,7 @@ "parameter_from_data", ] -from typing import TYPE_CHECKING, Dict, List, NewType, Set, Tuple, Union, cast +from typing import TYPE_CHECKING, NewType, Union, cast from urllib.parse import urlparse from attrs import define, evolve, field @@ -76,13 +76,13 @@ def from_string(*, string: str, config: Config) -> "Class": class Schemas: """Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)""" - classes_by_reference: Dict[ReferencePath, Property] = field(factory=dict) - dependencies: Dict[ReferencePath, Set[Union[ReferencePath, ClassName]]] = field(factory=dict) - classes_by_name: Dict[ClassName, Property] = field(factory=dict) - models_to_process: List[ModelProperty] = field(factory=list) - errors: List[ParseError] = field(factory=list) + classes_by_reference: dict[ReferencePath, Property] = field(factory=dict) + dependencies: dict[ReferencePath, set[Union[ReferencePath, ClassName]]] = field(factory=dict) + classes_by_name: dict[ClassName, Property] = field(factory=dict) + models_to_process: list[ModelProperty] = field(factory=list) + errors: list[ParseError] = field(factory=list) - def add_dependencies(self, ref_path: ReferencePath, roots: Set[Union[ReferencePath, ClassName]]) -> None: + def add_dependencies(self, ref_path: ReferencePath, roots: set[Union[ReferencePath, ClassName]]) -> None: """Record new dependencies on the given ReferencePath Args: @@ -143,9 +143,9 @@ def update_schemas_with_data( class Parameters: """Structure for containing all defined, shareable, and reusable parameters""" - classes_by_reference: Dict[ReferencePath, Parameter] = field(factory=dict) - classes_by_name: Dict[ClassName, Parameter] = field(factory=dict) - errors: List[ParseError] = field(factory=list) + classes_by_reference: dict[ReferencePath, Parameter] = field(factory=dict) + classes_by_name: dict[ClassName, Parameter] = field(factory=dict) + errors: list[ParseError] = field(factory=list) def parameter_from_data( @@ -154,7 +154,7 @@ def parameter_from_data( data: Union[oai.Reference, oai.Parameter], parameters: Parameters, config: Config, -) -> Tuple[Union[Parameter, ParameterError], Parameters]: +) -> tuple[Union[Parameter, ParameterError], Parameters]: """Generates parameters from an OpenAPI Parameter spec.""" if isinstance(data, oai.Reference): diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index 32412fd35..d313f81ad 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -1,7 +1,7 @@ __all__ = ["Response", "response_from_data"] from http import HTTPStatus -from typing import Optional, Tuple, TypedDict, Union +from typing import Optional, TypedDict, Union from attrs import define @@ -86,7 +86,7 @@ def response_from_data( schemas: Schemas, parent_name: str, config: Config, -) -> Tuple[Union[Response, ParseError], Schemas]: +) -> tuple[Union[Response, ParseError], Schemas]: """Generate a Response from the OpenAPI dictionary representation of it""" response_name = f"response_{status_code}" diff --git a/openapi_python_client/schema/openapi_schema_pydantic/callback.py b/openapi_python_client/schema/openapi_schema_pydantic/callback.py index 22426d925..f4593cc8d 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/callback.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/callback.py @@ -1,11 +1,11 @@ -from typing import TYPE_CHECKING, Dict +from typing import TYPE_CHECKING if TYPE_CHECKING: # pragma: no cover from .path_item import PathItem else: PathItem = "PathItem" -Callback = Dict[str, PathItem] +Callback = dict[str, PathItem] """ A map of possible out-of band callbacks related to the parent operation. Each value in the map is a [Path Item Object](#pathItemObject) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/components.py b/openapi_python_client/schema/openapi_schema_pydantic/components.py index f366a2ec8..4ff5f9edc 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/components.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/components.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional, Union +from typing import Optional, Union from pydantic import BaseModel, ConfigDict @@ -25,15 +25,15 @@ class Components(BaseModel): - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject """ - schemas: Optional[Dict[str, Union[Schema, Reference]]] = None - responses: Optional[Dict[str, Union[Response, Reference]]] = None - parameters: Optional[Dict[str, Union[Parameter, Reference]]] = None - examples: Optional[Dict[str, Union[Example, Reference]]] = None - requestBodies: Optional[Dict[str, Union[RequestBody, Reference]]] = None - headers: Optional[Dict[str, Union[Header, Reference]]] = None - securitySchemes: Optional[Dict[str, Union[SecurityScheme, Reference]]] = None - links: Optional[Dict[str, Union[Link, Reference]]] = None - callbacks: Optional[Dict[str, Union[Callback, Reference]]] = None + schemas: Optional[dict[str, Union[Schema, Reference]]] = None + responses: Optional[dict[str, Union[Response, Reference]]] = None + parameters: Optional[dict[str, Union[Parameter, Reference]]] = None + examples: Optional[dict[str, Union[Example, Reference]]] = None + requestBodies: Optional[dict[str, Union[RequestBody, Reference]]] = None + headers: Optional[dict[str, Union[Header, Reference]]] = None + securitySchemes: Optional[dict[str, Union[SecurityScheme, Reference]]] = None + links: Optional[dict[str, Union[Link, Reference]]] = None + callbacks: Optional[dict[str, Union[Callback, Reference]]] = None model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py b/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py index 95161d07a..9f36773ba 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/discriminator.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict @@ -19,7 +19,7 @@ class Discriminator(BaseModel): """ propertyName: str - mapping: Optional[Dict[str, str]] = None + mapping: Optional[dict[str, str]] = None model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/encoding.py b/openapi_python_client/schema/openapi_schema_pydantic/encoding.py index b7434c50c..78190363b 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/encoding.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/encoding.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Dict, Optional, Union +from typing import TYPE_CHECKING, Optional, Union from pydantic import BaseModel, ConfigDict @@ -19,7 +19,7 @@ class Encoding(BaseModel): """ contentType: Optional[str] = None - headers: Optional[Dict[str, Union[Header, Reference]]] = None + headers: Optional[dict[str, Union[Header, Reference]]] = None style: Optional[str] = None explode: bool = False allowReserved: bool = False diff --git a/openapi_python_client/schema/openapi_schema_pydantic/link.py b/openapi_python_client/schema/openapi_schema_pydantic/link.py index 9f823c4a2..69cdf29c0 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/link.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/link.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Optional from pydantic import BaseModel, ConfigDict @@ -25,7 +25,7 @@ class Link(BaseModel): operationRef: Optional[str] = None operationId: Optional[str] = None - parameters: Optional[Dict[str, Any]] = None + parameters: Optional[dict[str, Any]] = None requestBody: Optional[Any] = None description: Optional[str] = None server: Optional[Server] = None diff --git a/openapi_python_client/schema/openapi_schema_pydantic/media_type.py b/openapi_python_client/schema/openapi_schema_pydantic/media_type.py index 1bda99560..1e4d33b6d 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/media_type.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/media_type.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -18,8 +18,8 @@ class MediaType(BaseModel): media_type_schema: Optional[Union[Reference, Schema]] = Field(default=None, alias="schema") example: Optional[Any] = None - examples: Optional[Dict[str, Union[Example, Reference]]] = None - encoding: Optional[Dict[str, Encoding]] = None + examples: Optional[dict[str, Union[Example, Reference]]] = None + encoding: Optional[dict[str, Encoding]] = None model_config = ConfigDict( extra="allow", populate_by_name=True, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py b/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py index c7485814f..16e366090 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict @@ -15,7 +15,7 @@ class OAuthFlow(BaseModel): authorizationUrl: Optional[str] = None tokenUrl: Optional[str] = None refreshUrl: Optional[str] = None - scopes: Dict[str, str] + scopes: dict[str, str] model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/open_api.py b/openapi_python_client/schema/openapi_schema_pydantic/open_api.py index 6a1b5ae12..4282cfeb5 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/open_api.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/open_api.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict, field_validator @@ -25,11 +25,11 @@ class OpenAPI(BaseModel): """ info: Info - servers: List[Server] = [Server(url="/")] + servers: list[Server] = [Server(url="/")] paths: Paths components: Optional[Components] = None - security: Optional[List[SecurityRequirement]] = None - tags: Optional[List[Tag]] = None + security: Optional[list[SecurityRequirement]] = None + tags: Optional[list[Tag]] = None externalDocs: Optional[ExternalDocumentation] = None openapi: str model_config = ConfigDict(extra="allow") diff --git a/openapi_python_client/schema/openapi_schema_pydantic/operation.py b/openapi_python_client/schema/openapi_schema_pydantic/operation.py index 41f5e7100..2976e73bf 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/operation.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/operation.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union +from typing import Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -24,19 +24,19 @@ class Operation(BaseModel): - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject """ - tags: Optional[List[str]] = None + tags: Optional[list[str]] = None summary: Optional[str] = None description: Optional[str] = None externalDocs: Optional[ExternalDocumentation] = None operationId: Optional[str] = None - parameters: Optional[List[Union[Parameter, Reference]]] = None + parameters: Optional[list[Union[Parameter, Reference]]] = None request_body: Optional[Union[RequestBody, Reference]] = Field(None, alias="requestBody") responses: Responses - callbacks: Optional[Dict[str, Callback]] = None + callbacks: Optional[dict[str, Callback]] = None deprecated: bool = False - security: Optional[List[SecurityRequirement]] = None - servers: Optional[List[Server]] = None + security: Optional[list[SecurityRequirement]] = None + servers: Optional[list[Server]] = None model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/parameter.py b/openapi_python_client/schema/openapi_schema_pydantic/parameter.py index 25ba819f1..a46301026 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/parameter.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/parameter.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -32,8 +32,8 @@ class Parameter(BaseModel): allowReserved: bool = False param_schema: Optional[Union[Reference, Schema]] = Field(default=None, alias="schema") example: Optional[Any] = None - examples: Optional[Dict[str, Union[Example, Reference]]] = None - content: Optional[Dict[str, MediaType]] = None + examples: Optional[dict[str, Union[Example, Reference]]] = None + content: Optional[dict[str, MediaType]] = None model_config = ConfigDict( extra="allow", populate_by_name=True, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/path_item.py b/openapi_python_client/schema/openapi_schema_pydantic/path_item.py index 36edee0e3..2c68c88b8 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/path_item.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/path_item.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Union +from typing import Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -30,8 +30,8 @@ class PathItem(BaseModel): head: Optional["Operation"] = None patch: Optional["Operation"] = None trace: Optional["Operation"] = None - servers: Optional[List[Server]] = None - parameters: Optional[List[Union[Parameter, Reference]]] = None + servers: Optional[list[Server]] = None + parameters: Optional[list[Union[Parameter, Reference]]] = None model_config = ConfigDict( extra="allow", populate_by_name=True, diff --git a/openapi_python_client/schema/openapi_schema_pydantic/paths.py b/openapi_python_client/schema/openapi_schema_pydantic/paths.py index d61ea7b18..86c1dfd19 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/paths.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/paths.py @@ -1,8 +1,6 @@ -from typing import Dict - from .path_item import PathItem -Paths = Dict[str, PathItem] +Paths = dict[str, PathItem] """ Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL. diff --git a/openapi_python_client/schema/openapi_schema_pydantic/request_body.py b/openapi_python_client/schema/openapi_schema_pydantic/request_body.py index 6b1847215..feaa0c8ea 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/request_body.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/request_body.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict @@ -14,7 +14,7 @@ class RequestBody(BaseModel): """ description: Optional[str] = None - content: Dict[str, MediaType] + content: dict[str, MediaType] required: bool = False model_config = ConfigDict( extra="allow", diff --git a/openapi_python_client/schema/openapi_schema_pydantic/response.py b/openapi_python_client/schema/openapi_schema_pydantic/response.py index a7c5d08ec..5f5ac73bf 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/response.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/response.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional, Union +from typing import Optional, Union from pydantic import BaseModel, ConfigDict @@ -19,9 +19,9 @@ class Response(BaseModel): """ description: str - headers: Optional[Dict[str, Union[Header, Reference]]] = None - content: Optional[Dict[str, MediaType]] = None - links: Optional[Dict[str, Union[Link, Reference]]] = None + headers: Optional[dict[str, Union[Header, Reference]]] = None + content: Optional[dict[str, MediaType]] = None + links: Optional[dict[str, Union[Link, Reference]]] = None model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/responses.py b/openapi_python_client/schema/openapi_schema_pydantic/responses.py index 53306ae1c..17ddc13fe 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/responses.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/responses.py @@ -1,9 +1,9 @@ -from typing import Dict, Union +from typing import Union from .reference import Reference from .response import Response -Responses = Dict[str, Union[Response, Reference]] +Responses = dict[str, Union[Response, Reference]] """ A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. diff --git a/openapi_python_client/schema/openapi_schema_pydantic/schema.py b/openapi_python_client/schema/openapi_schema_pydantic/schema.py index d42ccc6ad..486664d5d 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/schema.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/schema.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, model_validator @@ -34,17 +34,17 @@ class Schema(BaseModel): uniqueItems: Optional[bool] = None maxProperties: Optional[int] = Field(default=None, ge=0) minProperties: Optional[int] = Field(default=None, ge=0) - required: Optional[List[str]] = Field(default=None) - enum: Union[None, List[Any]] = Field(default=None, min_length=1) + required: Optional[list[str]] = Field(default=None) + enum: Union[None, list[Any]] = Field(default=None, min_length=1) const: Union[None, StrictStr, StrictInt, StrictFloat, StrictBool] = None - type: Union[DataType, List[DataType], None] = Field(default=None) - allOf: List[Union[Reference, "Schema"]] = Field(default_factory=list) - oneOf: List[Union[Reference, "Schema"]] = Field(default_factory=list) - anyOf: List[Union[Reference, "Schema"]] = Field(default_factory=list) + type: Union[DataType, list[DataType], None] = Field(default=None) + allOf: list[Union[Reference, "Schema"]] = Field(default_factory=list) + oneOf: list[Union[Reference, "Schema"]] = Field(default_factory=list) + anyOf: list[Union[Reference, "Schema"]] = Field(default_factory=list) schema_not: Optional[Union[Reference, "Schema"]] = Field(default=None, alias="not") items: Optional[Union[Reference, "Schema"]] = None - prefixItems: Optional[List[Union[Reference, "Schema"]]] = Field(default_factory=list) - properties: Optional[Dict[str, Union[Reference, "Schema"]]] = None + prefixItems: Optional[list[Union[Reference, "Schema"]]] = Field(default_factory=list) + properties: Optional[dict[str, Union[Reference, "Schema"]]] = None additionalProperties: Optional[Union[bool, Reference, "Schema"]] = None description: Optional[str] = None schema_format: Optional[str] = Field(default=None, alias="format") diff --git a/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py b/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py index b3cca3b08..58a487dc7 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py @@ -1,6 +1,4 @@ -from typing import Dict, List - -SecurityRequirement = Dict[str, List[str]] +SecurityRequirement = dict[str, list[str]] """ Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the diff --git a/openapi_python_client/schema/openapi_schema_pydantic/server.py b/openapi_python_client/schema/openapi_schema_pydantic/server.py index d573a93fe..6bc21766c 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/server.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/server.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict @@ -15,7 +15,7 @@ class Server(BaseModel): url: str description: Optional[str] = None - variables: Optional[Dict[str, ServerVariable]] = None + variables: Optional[dict[str, ServerVariable]] = None model_config = ConfigDict( extra="allow", json_schema_extra={ diff --git a/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py b/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py index 3b63c9ad2..8a869c40e 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/server_variable.py @@ -1,4 +1,4 @@ -from typing import List, Optional +from typing import Optional from pydantic import BaseModel, ConfigDict @@ -11,7 +11,7 @@ class ServerVariable(BaseModel): - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#serverVariableObject """ - enum: Optional[List[str]] = None + enum: Optional[list[str]] = None default: str description: Optional[str] = None model_config = ConfigDict(extra="allow") diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index 4f224e6e8..aee6096e9 100644 --- a/openapi_python_client/templates/client.py.jinja +++ b/openapi_python_client/templates/client.py.jinja @@ -1,5 +1,5 @@ import ssl -from typing import Any, Dict, Union, Optional +from typing import Any, Union, Optional from attrs import define, field, evolve import httpx @@ -38,17 +38,17 @@ class Client: {% macro attributes() %} raise_on_unexpected_status: bool = field(default=False, kw_only=True) _base_url: str = field(alias="base_url") - _cookies: Dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") - _headers: Dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") _timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout") _verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl") _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") - _httpx_args: Dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") _client: Optional[httpx.Client] = field(default=None, init=False) _async_client: Optional[httpx.AsyncClient] = field(default=None, init=False) {% endmacro %}{{ attributes() }} {% macro builders(self) %} - def with_headers(self, headers: Dict[str, str]) -> "{{ self }}": + def with_headers(self, headers: dict[str, str]) -> "{{ self }}": """Get a new client matching this one with additional headers""" if self._client is not None: self._client.headers.update(headers) @@ -56,7 +56,7 @@ class Client: self._async_client.headers.update(headers) return evolve(self, headers={**self._headers, **headers}) - def with_cookies(self, cookies: Dict[str, str]) -> "{{ self }}": + def with_cookies(self, cookies: dict[str, str]) -> "{{ self }}": """Get a new client matching this one with additional cookies""" if self._client is not None: self._client.cookies.update(cookies) diff --git a/openapi_python_client/templates/endpoint_macros.py.jinja b/openapi_python_client/templates/endpoint_macros.py.jinja index 79ca33d57..2da580af4 100644 --- a/openapi_python_client/templates/endpoint_macros.py.jinja +++ b/openapi_python_client/templates/endpoint_macros.py.jinja @@ -3,7 +3,7 @@ {% macro header_params(endpoint) %} {% if endpoint.header_parameters or endpoint.bodies | length > 0 %} -headers: Dict[str, Any] = {} +headers: dict[str, Any] = {} {% if endpoint.header_parameters %} {% for parameter in endpoint.header_parameters %} {% import "property_templates/" + parameter.template as param_template %} @@ -37,7 +37,7 @@ if {{ parameter.python_name }} is not UNSET: {% macro query_params(endpoint) %} {% if endpoint.query_parameters %} -params: Dict[str, Any] = {} +params: dict[str, Any] = {} {% for property in endpoint.query_parameters %} {% set destination = property.python_name %} diff --git a/openapi_python_client/templates/endpoint_module.py.jinja b/openapi_python_client/templates/endpoint_module.py.jinja index d89f09367..35090614c 100644 --- a/openapi_python_client/templates/endpoint_module.py.jinja +++ b/openapi_python_client/templates/endpoint_module.py.jinja @@ -1,5 +1,5 @@ from http import HTTPStatus -from typing import Any, Dict, List, Optional, Union, cast +from typing import Any, Optional, Union, cast import httpx @@ -19,14 +19,14 @@ from ... import errors def _get_kwargs( {{ arguments(endpoint, include_client=False) | indent(4) }} -) -> Dict[str, Any]: +) -> dict[str, Any]: {{ header_params(endpoint) | indent(4) }} {{ cookie_params(endpoint) | indent(4) }} {{ query_params(endpoint) | indent(4) }} - _kwargs: Dict[str, Any] = { + _kwargs: dict[str, Any] = { "method": "{{ endpoint.method }}", {% if endpoint.path_parameters %} "url": "{{ endpoint.path }}".format( diff --git a/openapi_python_client/templates/literal_enum.py.jinja b/openapi_python_client/templates/literal_enum.py.jinja index df993adb7..72207efa3 100644 --- a/openapi_python_client/templates/literal_enum.py.jinja +++ b/openapi_python_client/templates/literal_enum.py.jinja @@ -1,8 +1,8 @@ -from typing import Literal, Set, cast +from typing import Literal, cast {{ enum.class_info.name }} = Literal{{ "%r" | format(enum.values|list|sort) }} -{{ enum.get_class_name_snake_case() | upper }}_VALUES: Set[{{ enum.class_info.name }}] = { {% for v in enum.values|list|sort %}{{"%r"|format(v)}}, {% endfor %} } +{{ enum.get_class_name_snake_case() | upper }}_VALUES: set[{{ enum.class_info.name }}] = { {% for v in enum.values|list|sort %}{{"%r"|format(v)}}, {% endfor %} } def check_{{ enum.get_class_name_snake_case() }}(value: {{ enum.get_instance_type_string() }}) -> {{ enum.class_info.name}}: if value in {{ enum.get_class_name_snake_case() | upper }}_VALUES: diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 012201426..739f68962 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -1,9 +1,4 @@ -from typing import Any, Dict, Type, TypeVar, Tuple, Optional, BinaryIO, TextIO, TYPE_CHECKING - -{% if model.additional_properties %} -from typing import List - -{% endif %} +from typing import Any, TypeVar, Optional, BinaryIO, TextIO, TYPE_CHECKING from attrs import define as _attrs_define from attrs import field as _attrs_field @@ -74,7 +69,7 @@ class {{ class_name }}: {% endif %} {% endfor %} {% if model.additional_properties %} - additional_properties: Dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict) {% endif %} {% macro _to_dict(multipart=False) %} @@ -90,7 +85,7 @@ class {{ class_name }}: {% endfor %} -field_dict: Dict[str, Any] = {} +field_dict: dict[str, Any] = {} {% if model.additional_properties %} {% import "property_templates/" + model.additional_properties.template as prop_template %} {% if multipart %} @@ -122,19 +117,19 @@ if {{ property.python_name }} is not UNSET: return field_dict {% endmacro %} - def to_dict(self) -> Dict[str, Any]: + def to_dict(self) -> dict[str, Any]: {% for lazy_import in model.lazy_imports %} {{ lazy_import }} {% endfor %} {{ _to_dict() | indent(8) }} {% if model.is_multipart_body %} - def to_multipart(self) -> Dict[str, Any]: + def to_multipart(self) -> dict[str, Any]: {{ _to_dict(multipart=True) | indent(8) }} {% endif %} @classmethod - def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: {% for lazy_import in model.lazy_imports %} {{ lazy_import }} {% endfor %} @@ -188,7 +183,7 @@ return field_dict {% if model.additional_properties %} @property - def additional_keys(self) -> List[str]: + def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> {{ additional_property_type }}: diff --git a/openapi_python_client/templates/property_templates/enum_property.py.jinja b/openapi_python_client/templates/property_templates/enum_property.py.jinja index ea9b66a51..c46538eac 100644 --- a/openapi_python_client/templates/property_templates/enum_property.py.jinja +++ b/openapi_python_client/templates/property_templates/enum_property.py.jinja @@ -24,7 +24,7 @@ if not isinstance({{ source }}, Unset): {% macro transform_multipart(property, source, destination) %} {% set transformed = "(None, str(" + source + ".value" + ").encode(), \"text/plain\")" %} -{% set type_string = "Union[Unset, Tuple[None, bytes, str]]" %} +{% set type_string = "Union[Unset, tuple[None, bytes, str]]" %} {% if property.required %} {{ destination }} = {{ transformed }} {%- else %} diff --git a/openapi_python_client/templates/property_templates/list_property.py.jinja b/openapi_python_client/templates/property_templates/list_property.py.jinja index c827b6d54..94a9c6d65 100644 --- a/openapi_python_client/templates/property_templates/list_property.py.jinja +++ b/openapi_python_client/templates/property_templates/list_property.py.jinja @@ -54,7 +54,7 @@ if not isinstance({{ source }}, Unset): {% macro transform_multipart(property, source, destination) %} {% set inner_property = property.inner_property %} -{% set type_string = "Union[Unset, Tuple[None, bytes, str]]" %} +{% set type_string = "Union[Unset, tuple[None, bytes, str]]" %} {% if property.required %} {{ _transform(property, source, destination, True, "to_dict") }} {% else %} diff --git a/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja b/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja index 680ebfabe..1506284d7 100644 --- a/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +++ b/openapi_python_client/templates/property_templates/literal_enum_property.py.jinja @@ -23,7 +23,7 @@ if not isinstance({{ source }}, Unset): {% macro transform_multipart(property, source, destination) %} {% set transformed = "(None, str(" + source + ").encode(), \"text/plain\")" %} -{% set type_string = "Union[Unset, Tuple[None, bytes, str]]" %} +{% set type_string = "Union[Unset, tuple[None, bytes, str]]" %} {% if property.required %} {{ destination }} = {{ transformed }} {%- else %} diff --git a/openapi_python_client/templates/pyproject.toml.jinja b/openapi_python_client/templates/pyproject.toml.jinja index 7f68d58e5..e480f6729 100644 --- a/openapi_python_client/templates/pyproject.toml.jinja +++ b/openapi_python_client/templates/pyproject.toml.jinja @@ -9,7 +9,7 @@ version = "{{ package_version }}" description = "{{ package_description }}" authors = [] readme = "README.md" -{% if pdm %}requires-python = ">=3.8,<4.0"{% endif %} +{% if pdm %}requires-python = ">=3.9,<4.0"{% endif %} {% if poetry %} packages = [ {include = "{{ package_name }}"}, @@ -30,7 +30,7 @@ distribution = true {% if poetry %} [tool.poetry.dependencies] -python = "^3.8" +python = "^3.9" httpx = ">=0.20.0,<0.28.0" attrs = ">=21.3.0" python-dateutil = "^2.8.0" diff --git a/openapi_python_client/templates/setup.py.jinja b/openapi_python_client/templates/setup.py.jinja index 87c0cc063..e577c28b9 100644 --- a/openapi_python_client/templates/setup.py.jinja +++ b/openapi_python_client/templates/setup.py.jinja @@ -12,7 +12,7 @@ setup( long_description=long_description, long_description_content_type="text/markdown", packages=find_packages(), - python_requires=">=3.8, <4", + python_requires=">=3.9, <4", install_requires=["httpx >= 0.20.0, < 0.28.0", "attrs >= 21.3.0", "python-dateutil >= 2.8.0, < 3"], package_data={"{{ package_name }}": ["py.typed"]}, ) diff --git a/openapi_python_client/templates/types.py.jinja b/openapi_python_client/templates/types.py.jinja index cc151acb3..65e87af47 100644 --- a/openapi_python_client/templates/types.py.jinja +++ b/openapi_python_client/templates/types.py.jinja @@ -1,6 +1,8 @@ """ Contains some shared types for properties """ + +from collections.abc import MutableMapping from http import HTTPStatus -from typing import Any, BinaryIO, Generic, MutableMapping, Optional, Tuple, TypeVar, Literal +from typing import BinaryIO, Generic, Optional, TypeVar, Literal from attrs import define @@ -13,7 +15,7 @@ class Unset: UNSET: Unset = Unset() {# Used as `FileProperty._json_type_string` #} -FileJsonType = Tuple[Optional[str], BinaryIO, Optional[str]] +FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] @define diff --git a/openapi_python_client/utils.py b/openapi_python_client/utils.py index 22a7bcfa8..15e8c9eec 100644 --- a/openapi_python_client/utils.py +++ b/openapi_python_client/utils.py @@ -57,7 +57,6 @@ def split_words(value: str) -> list[str]: RESERVED_WORDS = (set(dir(builtins)) | {"self", "true", "false", "datetime"}) - { - "type", "id", } diff --git a/pdm.lock b/pdm.lock index 6aca0368e..13dafbd8d 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,10 +5,10 @@ groups = ["default", "dev"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:b73d22dbc5f83e955263b2941d1ec9b6ef27a6487f3d274afd8e70f27e10c696" +content_hash = "sha256:54c7ff6db9dfa230f551918c71b6a59a51203d8f8dd3a53af8034c46a8eafd82" [[metadata.targets]] -requires_python = ">=3.8.1,<4.0" +requires_python = "~=3.9" [[package]] name = "annotated-types" @@ -750,7 +750,7 @@ files = [ [[package]] name = "rich" -version = "13.9.4" +version = "13.9.2" requires_python = ">=3.8.0" summary = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" groups = ["default"] @@ -760,8 +760,8 @@ dependencies = [ "typing-extensions<5.0,>=4.0.0; python_version < \"3.11\"", ] files = [ - {file = "rich-13.9.4-py3-none-any.whl", hash = "sha256:6049d5e6ec054bf2779ab3358186963bac2ea89175919d699e378b99738c2a90"}, - {file = "rich-13.9.4.tar.gz", hash = "sha256:439594978a49a09530cff7ebc4b5c7103ef57baf48d5ea3184f21d9a2befa098"}, + {file = "rich-13.9.2-py3-none-any.whl", hash = "sha256:8c82a3d3f8dcfe9e734771313e606b39d8247bb6b826e196f4914b333b743cf1"}, + {file = "rich-13.9.2.tar.gz", hash = "sha256:51a2c62057461aaf7152b4d611168f93a9fc73068f8ded2790f29fe2b5366d0c"}, ] [[package]] @@ -949,7 +949,7 @@ files = [ [[package]] name = "typer" -version = "0.13.0" +version = "0.12.5" requires_python = ">=3.7" summary = "Typer, build great CLIs. Easy to code. Based on Python type hints." groups = ["default"] @@ -960,8 +960,8 @@ dependencies = [ "typing-extensions>=3.7.4.3", ] files = [ - {file = "typer-0.13.0-py3-none-any.whl", hash = "sha256:d85fe0b777b2517cc99c8055ed735452f2659cd45e451507c76f48ce5c1d00e2"}, - {file = "typer-0.13.0.tar.gz", hash = "sha256:f1c7198347939361eec90139ffa0fd8b3df3a2259d5852a0f7400e476d95985c"}, + {file = "typer-0.12.5-py3-none-any.whl", hash = "sha256:62fe4e471711b147e3365034133904df3e235698399bc4de2b36c8579298d52b"}, + {file = "typer-0.12.5.tar.gz", hash = "sha256:f592f089bedcc8ec1b974125d64851029c3b1af145f04aca64d69410f0c9b722"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 68d7f18d3..cd94cefdd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ authors = [ { name = "Dylan Anthony", email = "contact@dylananthony.com" }, ] license = { text = "MIT" } -requires-python = ">=3.8.1,<4.0" +requires-python = ">=3.9,<4.0" dependencies = [ "jinja2>=3.0.0,<4.0.0", "typer>0.6,<0.14", @@ -30,7 +30,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Intended Audience :: Developers", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/tests/test_parser/test_properties/test_enum_property.py b/tests/test_parser/test_properties/test_enum_property.py index 21b183f8e..282298aaf 100644 --- a/tests/test_parser/test_properties/test_enum_property.py +++ b/tests/test_parser/test_properties/test_enum_property.py @@ -1,4 +1,4 @@ -from typing import Type, Union +from typing import Union import pytest @@ -8,7 +8,7 @@ from openapi_python_client.parser.properties import LiteralEnumProperty, Schemas from openapi_python_client.parser.properties.enum_property import EnumProperty -PropertyClass = Union[Type[EnumProperty], Type[LiteralEnumProperty]] +PropertyClass = Union[type[EnumProperty], type[LiteralEnumProperty]] @pytest.fixture(params=[EnumProperty, LiteralEnumProperty]) diff --git a/tests/test_parser/test_properties/test_init.py b/tests/test_parser/test_properties/test_init.py index f56bf065d..918defcdb 100644 --- a/tests/test_parser/test_properties/test_init.py +++ b/tests/test_parser/test_properties/test_init.py @@ -129,13 +129,13 @@ def test_is_base_type(self, list_property_factory): @pytest.mark.parametrize("quoted", (True, False)) def test_get_base_json_type_string_base_inner(self, list_property_factory, quoted): p = list_property_factory() - assert p.get_base_json_type_string(quoted=quoted) == "List[str]" + assert p.get_base_json_type_string(quoted=quoted) == "list[str]" @pytest.mark.parametrize("quoted", (True, False)) def test_get_base_json_type_string_model_inner(self, list_property_factory, model_property_factory, quoted): m = model_property_factory() p = list_property_factory(inner_property=m) - assert p.get_base_json_type_string(quoted=quoted) == "List[Dict[str, Any]]" + assert p.get_base_json_type_string(quoted=quoted) == "list[dict[str, Any]]" def test_get_lazy_import_base_inner(self, list_property_factory): p = list_property_factory() @@ -149,8 +149,8 @@ def test_get_lazy_import_model_inner(self, list_property_factory, model_property @pytest.mark.parametrize( "required, expected", ( - (True, "List[str]"), - (False, "Union[Unset, List[str]]"), + (True, "list[str]"), + (False, "Union[Unset, list[str]]"), ), ) def test_get_type_string_base_inner(self, list_property_factory, required, expected): @@ -161,8 +161,8 @@ def test_get_type_string_base_inner(self, list_property_factory, required, expec @pytest.mark.parametrize( "required, expected", ( - (True, "List['MyClass']"), - (False, "Union[Unset, List['MyClass']]"), + (True, "list['MyClass']"), + (False, "Union[Unset, list['MyClass']]"), ), ) def test_get_type_string_model_inner(self, list_property_factory, model_property_factory, required, expected): @@ -174,8 +174,8 @@ def test_get_type_string_model_inner(self, list_property_factory, model_property @pytest.mark.parametrize( "quoted,expected", [ - (False, "List[str]"), - (True, "List[str]"), + (False, "list[str]"), + (True, "list[str]"), ], ) def test_get_base_type_string_base_inner(self, list_property_factory, quoted, expected): @@ -185,8 +185,8 @@ def test_get_base_type_string_base_inner(self, list_property_factory, quoted, ex @pytest.mark.parametrize( "quoted,expected", [ - (False, "List['MyClass']"), - (True, "List['MyClass']"), + (False, "list['MyClass']"), + (True, "list['MyClass']"), ], ) def test_get_base_type_string_model_inner(self, list_property_factory, model_property_factory, quoted, expected): @@ -202,7 +202,6 @@ def test_get_type_imports(self, list_property_factory, date_time_property_factor "import datetime", "from typing import cast", "from dateutil.parser import isoparse", - "from typing import cast, List", } if not required: expected |= { diff --git a/tests/test_parser/test_properties/test_model_property.py b/tests/test_parser/test_properties/test_model_property.py index 8adc88e39..a51fd984b 100644 --- a/tests/test_parser/test_properties/test_model_property.py +++ b/tests/test_parser/test_properties/test_model_property.py @@ -19,12 +19,12 @@ class TestModelProperty: (False, True, False, False, "MyClass"), (True, False, False, False, "MyClass"), (True, True, False, False, "MyClass"), - (False, True, True, False, "Dict[str, Any]"), + (False, True, True, False, "dict[str, Any]"), (False, False, False, True, "Union[Unset, 'MyClass']"), (False, True, False, True, "'MyClass'"), (True, False, False, True, "'MyClass'"), (True, True, False, True, "'MyClass'"), - (False, True, True, True, "Dict[str, Any]"), + (False, True, True, True, "dict[str, Any]"), ], ) def test_get_type_string(self, no_optional, required, json, expected, model_property_factory, quoted): @@ -40,7 +40,6 @@ def test_get_imports(self, model_property_factory): assert prop.get_imports(prefix="..") == { "from typing import Union", "from ..types import UNSET, Unset", - "from typing import Dict", "from typing import cast", } @@ -719,8 +718,8 @@ def test_set_relative_imports(model_property_factory): from openapi_python_client.parser.properties import Class class_info = Class("ClassName", module_name="module_name") - relative_imports = {"from typing import List", f"from ..models.{class_info.module_name} import {class_info.name}"} + relative_imports = {f"from ..models.{class_info.module_name} import {class_info.name}"} model_property = model_property_factory(class_info=class_info, relative_imports=relative_imports) - assert model_property.relative_imports == {"from typing import List"} + assert model_property.relative_imports == set() diff --git a/tests/test_utils.py b/tests/test_utils.py index e7dccf9a8..fafa61805 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -99,7 +99,7 @@ def test_no_string_escapes(): ("int", "int_"), ("dict", "dict_"), ("not_reserved", "not_reserved"), - ("type", "type"), + ("type", "type_"), ("id", "id"), ("None", "None_"), ],