From c11d5d65ae00838d999e388e90d4ccbf8444cb61 Mon Sep 17 00:00:00 2001 From: Johnvox Date: Sun, 2 Aug 2026 17:06:19 +0200 Subject: [PATCH 1/5] fix: Ruff LazyImport PLC0415 --- openapi_python_client/templates/model.py.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 50bc36ca3..517f2b5c5 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -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) From 327851c0401640f44073290bfbe41b5698a62114 Mon Sep 17 00:00:00 2001 From: Johnvox Date: Sun, 2 Aug 2026 17:07:21 +0200 Subject: [PATCH 2/5] fix: Change Inherit from str,enum to StrEnum UP042 --- openapi_python_client/templates/str_enum.py.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3d83b0fe40da9ef6939f177e49eec8368624869f Mon Sep 17 00:00:00 2001 From: Jean-Yves NOLEN Date: Sun, 2 Aug 2026 17:16:16 +0200 Subject: [PATCH 3/5] ci: trigger From 854f2b71c6baa855db41c4849c9b13473ea23475 Mon Sep 17 00:00:00 2001 From: Jean-Yves NOLEN Date: Sun, 2 Aug 2026 17:30:58 +0200 Subject: [PATCH 4/5] fix: fix complains on PYI034 --- openapi_python_client/templates/client.py.jinja | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From a312eff6a9dc092106e0838257bf3bf9f4dcf1a6 Mon Sep 17 00:00:00 2001 From: Jean-Yves NOLEN Date: Sun, 2 Aug 2026 18:32:14 +0200 Subject: [PATCH 5/5] test: fix unit-test and e2e --- .../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 +- openapi_python_client/templates/model.py.jinja | 6 +++--- 38 files changed, 118 insertions(+), 110 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/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 517f2b5c5..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 = [] @@ -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 %}