From 2aae596b06b7058de8fc995a82357895fbc775bd Mon Sep 17 00:00:00 2001 From: Johnvox Date: Mon, 3 Aug 2026 05:22:16 +0200 Subject: [PATCH 1/4] fix: update generated code to use `StrEnum` and `-> Self` (#1474) Small changes to improve ruff checks --- .../my_test_api_client/client.py | 18 +++++++++--------- end_to_end_tests/generated_client.py | 4 ++-- .../golden-record/my_test_api_client/client.py | 18 +++++++++--------- .../my_test_api_client/models/a_model.py | 8 ++++---- .../models/an_all_of_enum.py | 4 ++-- ...th_a_circular_ref_in_items_object_a_item.py | 2 +- ...tems_object_additional_properties_a_item.py | 2 +- ...tems_object_additional_properties_b_item.py | 2 +- ...th_a_circular_ref_in_items_object_b_item.py | 2 +- .../my_test_api_client/models/an_enum.py | 4 ++-- .../models/an_enum_with_null.py | 4 ++-- .../models/another_all_of_sub_model_type.py | 4 ++-- .../body_upload_file_tests_upload_post.py | 16 +++++++++------- .../models/different_enum.py | 4 ++-- .../my_test_api_client/models/extended.py | 8 ++++---- ...location_header_types_string_enum_header.py | 4 ++-- .../models/get_models_allof_response_200.py | 4 ++-- .../models/http_validation_error.py | 2 +- ...model_with_additional_properties_inlined.py | 2 +- .../models/model_with_any_json_properties.py | 4 ++-- .../models/model_with_circular_ref_a.py | 2 +- .../models/model_with_circular_ref_b.py | 2 +- ..._circular_ref_in_additional_properties_a.py | 2 +- ..._circular_ref_in_additional_properties_b.py | 2 +- .../models/model_with_discriminated_union.py | 8 ++++---- ...el_with_merged_properties_string_to_enum.py | 4 ++-- ...del_with_primitive_additional_properties.py | 2 +- .../models/model_with_property_ref.py | 2 +- .../model_with_union_property_inlined.py | 12 +++++++++--- ...nions_simple_before_complex_response_200.py | 4 ++-- ...status_code_patterns_response_2xx_status.py | 4 ++-- .../my_enum_api_client/client.py | 18 +++++++++--------- .../test_3_1_features_client/client.py | 18 +++++++++--------- integration-tests/integration_tests/client.py | 18 +++++++++--------- .../models/post_body_multipart_body.py | 2 +- .../models/post_body_multipart_response_200.py | 4 ++-- .../integration_tests/models/public_error.py | 2 +- .../templates/client.py.jinja | 10 +++++----- openapi_python_client/templates/model.py.jinja | 8 ++++---- .../templates/str_enum.py.jinja | 4 ++-- 40 files changed, 126 insertions(+), 118 deletions(-) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py index 190510bac..a11b85c36 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/client.py @@ -1,5 +1,5 @@ import ssl -from typing import Any +from typing import Any, Self import httpx from attrs import define, evolve, field @@ -65,7 +65,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "Client": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -87,7 +87,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "Client": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -96,7 +96,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -118,7 +118,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "Client": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self @@ -195,7 +195,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -218,7 +218,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "AuthenticatedClient": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -227,7 +227,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -250,7 +250,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "AuthenticatedClient": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self diff --git a/end_to_end_tests/generated_client.py b/end_to_end_tests/generated_client.py index 9302ff549..2f22913f6 100644 --- a/end_to_end_tests/generated_client.py +++ b/end_to_end_tests/generated_client.py @@ -5,7 +5,7 @@ from pathlib import Path import sys import tempfile -from typing import Any +from typing import Any, Self from attrs import define import pytest @@ -29,7 +29,7 @@ class GeneratedClientContext: monkeypatch: pytest.MonkeyPatch old_modules: set[str] | None = None - def __enter__(self) -> "GeneratedClientContext": + def __enter__(self) -> Self: self.monkeypatch.syspath_prepend(self.output_path) self.old_modules = set(sys.modules.keys()) return self 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 1b7055ab8..edb246d7e 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 +from typing import Any, Self import httpx from attrs import define, evolve, field @@ -69,7 +69,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "Client": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -91,7 +91,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "Client": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -100,7 +100,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -122,7 +122,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "Client": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self @@ -203,7 +203,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -226,7 +226,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "AuthenticatedClient": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -235,7 +235,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -258,7 +258,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "AuthenticatedClient": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self 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 549d186ad..4ca83858f 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 @@ -81,8 +81,8 @@ class AModel: not_required_nullable_model: ModelWithUnionProperty | None | Unset = UNSET def to_dict(self) -> dict[str, Any]: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty + from ..models.free_form_model import FreeFormModel # noqa: PLC0415 + from ..models.model_with_union_property import ModelWithUnionProperty # noqa: PLC0415 an_enum_value = self.an_enum_value.value @@ -256,8 +256,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty + from ..models.free_form_model import FreeFormModel # noqa: PLC0415 + from ..models.model_with_union_property import ModelWithUnionProperty # noqa: PLC0415 d = dict(src_dict) an_enum_value = AnEnum(d.pop("an_enum_value")) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_all_of_enum.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_all_of_enum.py index 3aef48f8f..1439e1781 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_all_of_enum.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_all_of_enum.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class AnAllOfEnum(str, Enum): +class AnAllOfEnum(StrEnum): A_DEFAULT = "a_default" BAR = "bar" FOO = "foo" 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 8750fb194..77453bf2c 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 @@ -46,7 +46,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_b_item import ( - AnArrayWithACircularRefInItemsObjectBItem, + AnArrayWithACircularRefInItemsObjectBItem, # noqa: PLC0415 ) d = dict(src_dict) 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 11db3099b..a8a735b44 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 @@ -41,7 +41,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_b_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem, # noqa: PLC0415 ) d = dict(src_dict) 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 e330b3110..f7d6bcb21 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 @@ -41,7 +41,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_additional_properties_a_item import ( - AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, + AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem, # noqa: PLC0415 ) d = dict(src_dict) 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 0d4f07ece..e4039d6be 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 @@ -46,7 +46,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.an_array_with_a_circular_ref_in_items_object_a_item import ( - AnArrayWithACircularRefInItemsObjectAItem, + AnArrayWithACircularRefInItemsObjectAItem, # noqa: PLC0415 ) d = dict(src_dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_enum.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_enum.py index c266d0763..fe9c407d8 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_enum.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_enum.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class AnEnum(str, Enum): +class AnEnum(StrEnum): FIRST_VALUE = "FIRST_VALUE" SECOND_VALUE = "SECOND_VALUE" diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/an_enum_with_null.py b/end_to_end_tests/golden-record/my_test_api_client/models/an_enum_with_null.py index b1d6611e0..002ee3667 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/an_enum_with_null.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/an_enum_with_null.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class AnEnumWithNull(str, Enum): +class AnEnumWithNull(StrEnum): FIRST_VALUE = "FIRST_VALUE" SECOND_VALUE = "SECOND_VALUE" diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model_type.py b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model_type.py index b2e82aa7c..61d3a0c57 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model_type.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/another_all_of_sub_model_type.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class AnotherAllOfSubModelType(str, Enum): +class AnotherAllOfSubModelType(StrEnum): SUBMODEL = "submodel" def __str__(self) -> str: 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 a2c5bbe8c..0b8caee2c 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 @@ -70,7 +70,7 @@ class BodyUploadFileTestsUploadPost: def to_dict(self) -> dict[str, Any]: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, + BodyUploadFileTestsUploadPostSomeNullableObject, # noqa: PLC0415 ) some_file = self.some_file.to_tuple() @@ -172,7 +172,7 @@ def to_dict(self) -> dict[str, Any]: def to_multipart(self) -> types.RequestFiles: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, + BodyUploadFileTestsUploadPostSomeNullableObject, # noqa: PLC0415 ) files: types.RequestFiles = [] @@ -251,16 +251,18 @@ def to_multipart(self) -> types.RequestFiles: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.a_form_data import AFormData + from ..models.a_form_data import AFormData # noqa: PLC0415 from ..models.body_upload_file_tests_upload_post_additional_property import ( - BodyUploadFileTestsUploadPostAdditionalProperty, + BodyUploadFileTestsUploadPostAdditionalProperty, # noqa: PLC0415 ) from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( - BodyUploadFileTestsUploadPostSomeNullableObject, + BodyUploadFileTestsUploadPostSomeNullableObject, # noqa: PLC0415 + ) + from ..models.body_upload_file_tests_upload_post_some_object import ( + BodyUploadFileTestsUploadPostSomeObject, # noqa: PLC0415 ) - from ..models.body_upload_file_tests_upload_post_some_object import BodyUploadFileTestsUploadPostSomeObject from ..models.body_upload_file_tests_upload_post_some_optional_object import ( - BodyUploadFileTestsUploadPostSomeOptionalObject, + BodyUploadFileTestsUploadPostSomeOptionalObject, # noqa: PLC0415 ) d = dict(src_dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/different_enum.py b/end_to_end_tests/golden-record/my_test_api_client/models/different_enum.py index 6c167f25c..3aa4aa4df 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/different_enum.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/different_enum.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class DifferentEnum(str, Enum): +class DifferentEnum(StrEnum): DIFFERENT = "DIFFERENT" OTHER = "OTHER" 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 f25651a56..cf4966bf0 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 @@ -84,8 +84,8 @@ class Extended: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty + from ..models.free_form_model import FreeFormModel # noqa: PLC0415 + from ..models.model_with_union_property import ModelWithUnionProperty # noqa: PLC0415 an_enum_value = self.an_enum_value.value @@ -263,8 +263,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.free_form_model import FreeFormModel - from ..models.model_with_union_property import ModelWithUnionProperty + from ..models.free_form_model import FreeFormModel # noqa: PLC0415 + from ..models.model_with_union_property import ModelWithUnionProperty # noqa: PLC0415 d = dict(src_dict) an_enum_value = AnEnum(d.pop("an_enum_value")) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py b/end_to_end_tests/golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py index cce92dcde..2a5242fe5 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/get_location_header_types_string_enum_header.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class GetLocationHeaderTypesStringEnumHeader(str, Enum): +class GetLocationHeaderTypesStringEnumHeader(StrEnum): ONE = "one" THREE = "three" TWO = "two" 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 03b423308..9ec5f68c8 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 @@ -57,8 +57,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.a_model import AModel - from ..models.extended import Extended + from ..models.a_model import AModel # noqa: PLC0415 + from ..models.extended import Extended # noqa: PLC0415 d = dict(src_dict) _aliased = d.pop("aliased", UNSET) 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 4d982caee..7ed970dde 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 @@ -41,7 +41,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.validation_error import ValidationError + from ..models.validation_error import ValidationError # noqa: PLC0415 d = dict(src_dict) _detail = d.pop("detail", UNSET) 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 9cef96f7c..c1ca5e44c 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 @@ -45,7 +45,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.model_with_additional_properties_inlined_additional_property import ( - ModelWithAdditionalPropertiesInlinedAdditionalProperty, + ModelWithAdditionalPropertiesInlinedAdditionalProperty, # noqa: PLC0415 ) d = dict(src_dict) 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 7b59d8c2f..2fed0b38b 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 @@ -25,7 +25,7 @@ class ModelWithAnyJsonProperties: def to_dict(self) -> dict[str, Any]: from ..models.model_with_any_json_properties_additional_property_type_0 import ( - ModelWithAnyJsonPropertiesAdditionalPropertyType0, + ModelWithAnyJsonPropertiesAdditionalPropertyType0, # noqa: PLC0415 ) field_dict: dict[str, Any] = {} @@ -43,7 +43,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.model_with_any_json_properties_additional_property_type_0 import ( - ModelWithAnyJsonPropertiesAdditionalPropertyType0, + ModelWithAnyJsonPropertiesAdditionalPropertyType0, # noqa: PLC0415 ) d = dict(src_dict) 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 5e9849159..a9bde2daf 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 @@ -40,7 +40,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.model_with_circular_ref_b import ModelWithCircularRefB + from ..models.model_with_circular_ref_b import ModelWithCircularRefB # noqa: PLC0415 d = dict(src_dict) _circular = d.pop("circular", UNSET) 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 1a0e61354..c21d33148 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 @@ -40,7 +40,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.model_with_circular_ref_a import ModelWithCircularRefA + from ..models.model_with_circular_ref_a import ModelWithCircularRefA # noqa: PLC0415 d = dict(src_dict) _circular = d.pop("circular", UNSET) 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 0b1e0dbd1..a0fa52dbd 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 @@ -32,7 +32,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.model_with_circular_ref_in_additional_properties_b import ( - ModelWithCircularRefInAdditionalPropertiesB, + ModelWithCircularRefInAdditionalPropertiesB, # noqa: PLC0415 ) d = dict(src_dict) 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 e03dcfb6a..080ba46ad 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 @@ -32,7 +32,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.model_with_circular_ref_in_additional_properties_a import ( - ModelWithCircularRefInAdditionalPropertiesA, + ModelWithCircularRefInAdditionalPropertiesA, # noqa: PLC0415 ) d = dict(src_dict) 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 0e0021611..41b972dc4 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 @@ -27,8 +27,8 @@ class ModelWithDiscriminatedUnion: additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) 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 + from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 # noqa: PLC0415 + from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 # noqa: PLC0415 discriminated_union: dict[str, Any] | None | Unset if isinstance(self.discriminated_union, Unset): @@ -50,8 +50,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 - from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 + from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 # noqa: PLC0415 + from ..models.a_discriminated_union_type_2 import ADiscriminatedUnionType2 # noqa: PLC0415 d = dict(src_dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py index 5e146c5eb..22fb32812 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/model_with_merged_properties_string_to_enum.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class ModelWithMergedPropertiesStringToEnum(str, Enum): +class ModelWithMergedPropertiesStringToEnum(StrEnum): A = "a" B = "b" 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 2f4bf9de8..f4d01fd3f 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 @@ -43,7 +43,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.model_with_primitive_additional_properties_a_date_holder import ( - ModelWithPrimitiveAdditionalPropertiesADateHolder, + ModelWithPrimitiveAdditionalPropertiesADateHolder, # noqa: PLC0415 ) d = dict(src_dict) 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 19b63447d..622c94fa4 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 @@ -40,7 +40,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.model_name import ModelName + from ..models.model_name import ModelName # noqa: PLC0415 d = dict(src_dict) _inner = d.pop("inner", 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 ab144ded1..fbce31507 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 @@ -25,7 +25,9 @@ class ModelWithUnionPropertyInlined: fruit: ModelWithUnionPropertyInlinedApples | ModelWithUnionPropertyInlinedBananas | Unset = UNSET def to_dict(self) -> dict[str, Any]: - from ..models.model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples + from ..models.model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, # noqa: PLC0415 + ) fruit: dict[str, Any] | Unset if isinstance(self.fruit, Unset): @@ -45,8 +47,12 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples - from ..models.model_with_union_property_inlined_bananas import ModelWithUnionPropertyInlinedBananas + from ..models.model_with_union_property_inlined_apples import ( + ModelWithUnionPropertyInlinedApples, # noqa: PLC0415 + ) + from ..models.model_with_union_property_inlined_bananas import ( + ModelWithUnionPropertyInlinedBananas, # noqa: PLC0415 + ) d = dict(src_dict) 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 41685d494..205a1cd30 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 @@ -27,7 +27,7 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200: def to_dict(self) -> dict[str, Any]: from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, # noqa: PLC0415 ) a: dict[str, Any] | str @@ -49,7 +49,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( - PostResponsesUnionsSimpleBeforeComplexResponse200AType1, + PostResponsesUnionsSimpleBeforeComplexResponse200AType1, # noqa: PLC0415 ) d = dict(src_dict) diff --git a/end_to_end_tests/golden-record/my_test_api_client/models/status_code_patterns_response_2xx_status.py b/end_to_end_tests/golden-record/my_test_api_client/models/status_code_patterns_response_2xx_status.py index 0baaf6da8..9e871d06d 100644 --- a/end_to_end_tests/golden-record/my_test_api_client/models/status_code_patterns_response_2xx_status.py +++ b/end_to_end_tests/golden-record/my_test_api_client/models/status_code_patterns_response_2xx_status.py @@ -1,7 +1,7 @@ -from enum import Enum +from enum import StrEnum -class StatusCodePatternsResponse2XXStatus(str, Enum): +class StatusCodePatternsResponse2XXStatus(StrEnum): FAILURE = "failure" SUCCESS = "success" 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 1b7055ab8..edb246d7e 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 +from typing import Any, Self import httpx from attrs import define, evolve, field @@ -69,7 +69,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "Client": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -91,7 +91,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "Client": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -100,7 +100,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -122,7 +122,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "Client": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self @@ -203,7 +203,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -226,7 +226,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "AuthenticatedClient": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -235,7 +235,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -258,7 +258,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "AuthenticatedClient": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self 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 1b7055ab8..edb246d7e 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 +from typing import Any, Self import httpx from attrs import define, evolve, field @@ -69,7 +69,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "Client": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -91,7 +91,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "Client": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -100,7 +100,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -122,7 +122,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "Client": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self @@ -203,7 +203,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -226,7 +226,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "AuthenticatedClient": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -235,7 +235,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -258,7 +258,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "AuthenticatedClient": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self diff --git a/integration-tests/integration_tests/client.py b/integration-tests/integration_tests/client.py index 1b7055ab8..edb246d7e 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 +from typing import Any, Self import httpx from attrs import define, evolve, field @@ -69,7 +69,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "Client": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -91,7 +91,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "Client": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -100,7 +100,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -122,7 +122,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "Client": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self @@ -203,7 +203,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": self._async_client.timeout = timeout return evolve(self, timeout=timeout) - def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -226,7 +226,7 @@ def get_httpx_client(self) -> httpx.Client: ) return self._client - def __enter__(self) -> "AuthenticatedClient": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -235,7 +235,7 @@ def __exit__(self, *args: Any, **kwargs: Any) -> None: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -258,7 +258,7 @@ def get_async_httpx_client(self) -> httpx.AsyncClient: ) return self._async_client - async def __aenter__(self) -> "AuthenticatedClient": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self 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 91eb8159d..0882f881b 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_body.py +++ b/integration-tests/integration_tests/models/post_body_multipart_body.py @@ -95,7 +95,7 @@ def to_multipart(self) -> types.RequestFiles: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.an_object import AnObject + from ..models.an_object import AnObject # noqa: PLC0415 d = dict(src_dict) a_string = d.pop("a_string") 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 e0827c97c..be63512d2 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 @@ -69,8 +69,8 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.an_object import AnObject - from ..models.file import File + from ..models.an_object import AnObject # noqa: PLC0415 + from ..models.file import File # noqa: PLC0415 d = dict(src_dict) a_string = d.pop("a_string") diff --git a/integration-tests/integration_tests/models/public_error.py b/integration-tests/integration_tests/models/public_error.py index 40c711bed..b4ca256d2 100644 --- a/integration-tests/integration_tests/models/public_error.py +++ b/integration-tests/integration_tests/models/public_error.py @@ -67,7 +67,7 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - from ..models.problem import Problem + from ..models.problem import Problem # noqa: PLC0415 d = dict(src_dict) errors = cast(list[str], d.pop("errors", UNSET)) diff --git a/openapi_python_client/templates/client.py.jinja b/openapi_python_client/templates/client.py.jinja index 90c90a210..a8c4ac5c1 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 +from typing import Any, Self from attrs import define, field, evolve import httpx @@ -98,7 +98,7 @@ class Client: return evolve(self, timeout=timeout) {% endmacro %}{{ builders("Client") }} {% macro httpx_stuff(name, custom_constructor=None) %} - def set_httpx_client(self, client: httpx.Client) -> "{{ name }}": + def set_httpx_client(self, client: httpx.Client) -> Self: """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -123,7 +123,7 @@ class Client: ) return self._client - def __enter__(self) -> "{{ name }}": + def __enter__(self) -> Self: """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" self.get_httpx_client().__enter__() return self @@ -132,7 +132,7 @@ class Client: """Exit a context manager for internal httpx.Client (see httpx docs)""" self.get_httpx_client().__exit__(*args, **kwargs) - def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "{{ name }}": + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> Self: """Manually set the underlying httpx.AsyncClient **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. @@ -157,7 +157,7 @@ class Client: ) return self._async_client - async def __aenter__(self) -> "{{ name }}": + async def __aenter__(self) -> Self: """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" await self.get_async_httpx_client().__aenter__() return self diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 50bc36ca3..06a71cb22 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -145,14 +145,14 @@ return field_dict def to_dict(self) -> dict[str, Any]: {% for lazy_import in model.lazy_imports | sort %} - {{ lazy_import }} + {{ lazy_import }} # noqa: PLC0415 {% endfor %} {{ _to_dict() | indent(8) }} {% if model.is_multipart_body %} def to_multipart(self) -> types.RequestFiles: {% for lazy_import in model.lazy_imports | sort %} - {{ lazy_import }} + {{ lazy_import }} # noqa: PLC0415 {% endfor %} files: types.RequestFiles = [] @@ -174,7 +174,7 @@ return field_dict @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: {% for lazy_import in model.lazy_imports | sort %} - {{ lazy_import }} + {{ lazy_import }} # noqa: PLC0415 {% endfor %} {% if (model.required_properties or model.optional_properties or model.additional_properties) %} d = dict(src_dict) @@ -205,7 +205,7 @@ return field_dict {% if model.additional_properties.lazy_imports %} {% for lazy_import in model.additional_properties.lazy_imports | sort %} - {{ lazy_import }} + {{ lazy_import }} # noqa: PLC0415 {% endfor %} {% endif %} {% else %} diff --git a/openapi_python_client/templates/str_enum.py.jinja b/openapi_python_client/templates/str_enum.py.jinja index e0da5ed0f..ba47032a5 100644 --- a/openapi_python_client/templates/str_enum.py.jinja +++ b/openapi_python_client/templates/str_enum.py.jinja @@ -1,6 +1,6 @@ -from enum import Enum +from enum import StrEnum -class {{ enum.class_info.name }}(str, Enum): +class {{ enum.class_info.name }}(StrEnum): {% for key, value in enum.values|dictsort(true) %} {{ key }} = "{{ value }}" {% endfor %} From 2216c15715e45cb1cee67b49929136f134013954 Mon Sep 17 00:00:00 2001 From: Laurence de Jong Date: Mon, 3 Aug 2026 16:47:47 +0200 Subject: [PATCH 2/4] feat: Update `uv_build` to 0.12 when using `--meta=uv` (#1473) `uv` 0.12.0 is now the latest stable release on PyPI. - https://github.com/astral-sh/uv/releases/tag/0.12.0 Continues the existing pattern of tracking each new uv minor (#1352, #1396, #1434). Closes #1472 Co-authored-by: Laurence de Jong Co-authored-by: johnthagen --- end_to_end_tests/metadata_snapshots/uv.pyproject.toml | 2 +- openapi_python_client/templates/pyproject_uv.toml.jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/end_to_end_tests/metadata_snapshots/uv.pyproject.toml b/end_to_end_tests/metadata_snapshots/uv.pyproject.toml index 26153e44a..553582723 100644 --- a/end_to_end_tests/metadata_snapshots/uv.pyproject.toml +++ b/end_to_end_tests/metadata_snapshots/uv.pyproject.toml @@ -15,7 +15,7 @@ module-name = "test_3_1_features_client" module-root = "" [build-system] -requires = ["uv_build>=0.11.0,<0.12.0"] +requires = ["uv_build>=0.12.0,<0.13.0"] build-backend = "uv_build" [tool.ruff] diff --git a/openapi_python_client/templates/pyproject_uv.toml.jinja b/openapi_python_client/templates/pyproject_uv.toml.jinja index c14366320..dc5861af3 100644 --- a/openapi_python_client/templates/pyproject_uv.toml.jinja +++ b/openapi_python_client/templates/pyproject_uv.toml.jinja @@ -15,5 +15,5 @@ module-name = "{{ package_name }}" module-root = "" [build-system] -requires = ["uv_build>=0.11.0,<0.12.0"] +requires = ["uv_build>=0.12.0,<0.13.0"] build-backend = "uv_build" From edaae669369d3b97ca8a930ad689c5606b799188 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Tue, 4 Aug 2026 10:37:25 -0400 Subject: [PATCH 3/4] fix: Remove trailing spaces in README example code (#1475) Ruff 0.16 has started Python formatting code blocks in README files - https://astral.sh/blog/ruff-v0.16.0#markdown-code-block-formatting Remove some trailing spaces to reduce the diff if users format the generated README. --- .../docstrings-on-attributes-golden-record/README.md | 4 ++-- end_to_end_tests/golden-record/README.md | 4 ++-- end_to_end_tests/literal-enums-golden-record/README.md | 4 ++-- end_to_end_tests/test-3-1-golden-record/README.md | 4 ++-- integration-tests/README.md | 4 ++-- openapi_python_client/templates/README.md.jinja | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/end_to_end_tests/docstrings-on-attributes-golden-record/README.md b/end_to_end_tests/docstrings-on-attributes-golden-record/README.md index 79b20f411..32f776550 100644 --- a/end_to_end_tests/docstrings-on-attributes-golden-record/README.md +++ b/end_to_end_tests/docstrings-on-attributes-golden-record/README.md @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) diff --git a/end_to_end_tests/golden-record/README.md b/end_to_end_tests/golden-record/README.md index 79b20f411..32f776550 100644 --- a/end_to_end_tests/golden-record/README.md +++ b/end_to_end_tests/golden-record/README.md @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) diff --git a/end_to_end_tests/literal-enums-golden-record/README.md b/end_to_end_tests/literal-enums-golden-record/README.md index 2c6268349..025b5d402 100644 --- a/end_to_end_tests/literal-enums-golden-record/README.md +++ b/end_to_end_tests/literal-enums-golden-record/README.md @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) diff --git a/end_to_end_tests/test-3-1-golden-record/README.md b/end_to_end_tests/test-3-1-golden-record/README.md index dbe8a5c1e..352824967 100644 --- a/end_to_end_tests/test-3-1-golden-record/README.md +++ b/end_to_end_tests/test-3-1-golden-record/README.md @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) diff --git a/integration-tests/README.md b/integration-tests/README.md index f92972290..ec94ebc0a 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) diff --git a/openapi_python_client/templates/README.md.jinja b/openapi_python_client/templates/README.md.jinja index 98dcdf3a7..66a9c1669 100644 --- a/openapi_python_client/templates/README.md.jinja +++ b/openapi_python_client/templates/README.md.jinja @@ -47,7 +47,7 @@ By default, when you're calling an HTTPS API it will attempt to verify that SSL ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl="/path/to/certificate_bundle.pem", ) @@ -57,7 +57,7 @@ You can also disable certificate validation altogether, but beware that **this i ```python client = AuthenticatedClient( - base_url="https://internal_api.example.com", + base_url="https://internal_api.example.com", token="SuperSecretToken", verify_ssl=False ) From ee9a8c435b92e7425a0b68be2d42bae977bf7526 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 9 Aug 2026 15:54:28 -0600 Subject: [PATCH 4/4] chore(deps): update pypa/gh-action-pypi-publish action to v1.14.2 (#1476) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pypa/gh-action-pypi-publish](https://redirect.github.com/pypa/gh-action-pypi-publish) | action | patch | `v1.14.1` → `v1.14.2` | --- ### Release Notes
pypa/gh-action-pypi-publish (pypa/gh-action-pypi-publish) ### [`v1.14.2`](https://redirect.github.com/pypa/gh-action-pypi-publish/releases/tag/v1.14.2) [Compare Source](https://redirect.github.com/pypa/gh-action-pypi-publish/compare/v1.14.1...v1.14.2)

This one probably won't touch you visibly so just bookmark @​webknjaz's EuroPython 2026 “AI” slop rant for when it's published on YouTube or encourage him to come back with more to share next year!

#### 🛠️ Urgh… Another release!? Again? Explain yourself! Looking at the diff, you'll only witness updates across the dependency tree. That's it! It's not a security fix or anything like that even, no. But you'll want this update. > \[!tip] > So what *most* people will find useful is [@​takluyver](https://redirect.github.com/takluyver)[💰](https://redirect.github.com/sponsors/takluyver)'s update of Twine to v7 that we use internally ([#​416](https://redirect.github.com/pypa/gh-action-pypi-publish/issues/416)). This version will let them upload their sdists and wheels containing core packaging metadata v2.5 to (Test)PyPI. #### 🧐 Tell me why..
The rest of the updates bump things related to pypi-attestations and sigstore, which has the most interesting backstory here. @​facutuesca💰 sent a patch in #​417 but a bunch more helped out. TL;DR non-pure-python projects with C-extensions tend to have dozens (sometimes hundreds) wheels to upload to PyPI per release. They are often quite big and take time to transfer over the network. People started noticing problems and coming up with DIY sharding workarounds like [aio-libs/aiohttp#13226](https://redirect.github.com/aio-libs/aiohttp/pull/13226) around July 23. On this date, projects with a good amount of bytes to publish would start getting timeouts 5 minutes after the PyPI publishing job begun. The same job that worked just fine before. I had to start pinging upstream library and ecosystem people, on GitHub and privately, to start making sense of what was happening. Eventually, we collectively concluded that GitHub must've shortened the lifetime of their OIDC identity — it seems to have used to be 10 minutes long (at some point in the past) and is now 5 minutes, apparently. It's not documented clearly, and we have not been able to get any clarity by attempting to contact GitHub through private channels, using personal connections. Over the course of investigation, [@​facutuesca](https://redirect.github.com/facutuesca)[💰](https://redirect.github.com/sponsors/facutuesca) found and fixed a related underlying cache invalidation bug in [sigstore/sigstore-python#1838](https://redirect.github.com/sigstore/sigstore-python/pull/1838), which he then coordinated propagation through the dependency chain updates in sigstore-python, pypi-attestations, gh-action-pypi-publish and gh-action-sigstore-python. Mike's also discovered that Sigstore's Rekor slowdown seems to have become the main contributing cause of the last week's incident. He's collected some data to support this claim: .
Edge Cake
XKCD feels just like this release
#### 🫶 New Contributors - [@​davidbrochart](https://redirect.github.com/davidbrochart) made their first contribution in [#​415](https://redirect.github.com/pypa/gh-action-pypi-publish/issues/415) - [@​takluyver](https://redirect.github.com/takluyver) made their first contribution in [#​416](https://redirect.github.com/pypa/gh-action-pypi-publish/issues/416) **🪞 Full Diff**: **🧔‍♂️ Release Manager:** [@​webknjaz](https://redirect.github.com/sponsors/webknjaz) [🇺🇦](https://stand-with-ukraine.pp.ua) **🙏 Special Thanks** to [@​davidbrochart](https://redirect.github.com/davidbrochart)[💰](https://redirect.github.com/sponsors/davidbrochart) and [@​Dreamsorcerer](https://redirect.github.com/Dreamsorcerer)[💰](https://redirect.github.com/sponsors/Dreamsorcerer) for turning my attention (in [#​415](https://redirect.github.com/pypa/gh-action-pypi-publish/issues/415) and in private) to the newly surfaced corner case in GitHub's behavior that only affected a narrow category of projects while many others remained blissfully unaware. [@​bdraco](https://redirect.github.com/bdraco)[💰](https://redirect.github.com/sponsors/bdraco) came up with a DIY sharding workaround for aiohttp that served as a demo for other projects. [@​miketheman](https://redirect.github.com/miketheman)[💰](https://redirect.github.com/sponsors/miketheman) confirmed the Warehouse-side details. Also, [@​jku](https://redirect.github.com/jku)[💰](https://redirect.github.com/sponsors/jku) and [@​woodruffw](https://redirect.github.com/woodruffw)[💰](https://redirect.github.com/sponsors/woodruffw) helped work through, review and release the Sigstore ecosystem upstream libs. **💬 Discuss** [on Bluesky 🦋](https://bsky.app/profile/did:plc:ve6s3mxkefjaxty3m4fdqumn/post/3mrsqy2xba22j), [on Mastodon 🐘](https://mastodon.social/@​webknjaz/117005132816750073) and [on GitHub][release discussion]. [![GH Sponsors badge]][GH Sponsors URL] [GH Sponsors badge]: https://img.shields.io/badge/%40webknjaz-transparent?logo=githubsponsors&logoColor=%23EA4AAA&label=Sponsor&color=2a313c [GH Sponsors URL]: https://redirect.github.com/sponsors/webknjaz [release discussion]: https://redirect.github.com/pypa/gh-action-pypi-publish/discussions/419
--- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/openapi-generators/openapi-python-client). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d21d582a..163bb4ab5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,6 @@ jobs: - name: Build run: hatchling build - name: Push to PyPI - uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1 + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 with: attestations: true