From 331279bdec63603921f1aa58229ad450a72ff230 Mon Sep 17 00:00:00 2001 From: Armando Belardo <11140328+armandobelardo@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:59:37 -0400 Subject: [PATCH] fix: python retry wrapper leverages the right types (#3204) --- generators/python/core_utilities/sdk/http_client.py | 11 ++++++++--- generators/python/sdk/CHANGELOG.md | 4 ++++ generators/python/sdk/VERSION | 2 +- seed/python-sdk/alias/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/alias/tests/utilities.py | 2 +- .../api-wide-base-path/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/api-wide-base-path/tests/utilities.py | 2 +- .../python-sdk/audiences/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/audiences/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../auth-environment-variables/tests/utilities.py | 2 +- .../basic-auth/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/basic-auth/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../tests/utilities.py | 2 +- seed/python-sdk/bytes/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/bytes/tests/utilities.py | 2 +- .../circular-references/src/seed/core/http_client.py | 11 ++++++++--- .../python-sdk/circular-references/tests/utilities.py | 2 +- .../code-samples/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/code-samples/tests/utilities.py | 2 +- .../custom-auth/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/custom-auth/tests/utilities.py | 2 +- .../no-custom-config/src/seed/core/http_client.py | 11 ++++++++--- .../enum/no-custom-config/tests/utilities.py | 2 +- .../enum/strenum/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/enum/strenum/tests/utilities.py | 2 +- .../error-property/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/error-property/tests/utilities.py | 2 +- .../client-filename/src/seed/core/http_client.py | 11 ++++++++--- .../examples/client-filename/tests/utilities.py | 2 +- .../no-custom-config/src/seed/core/http_client.py | 11 ++++++++--- .../examples/no-custom-config/tests/utilities.py | 2 +- seed/python-sdk/exhaustive/additional_init_exports | 2 +- .../extra_dependencies/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/extra_dependencies/tests/utilities.py | 2 +- .../five-second-timeout/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/five-second-timeout/tests/utilities.py | 2 +- .../improved_imports/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/improved_imports/tests/utilities.py | 2 +- .../infinite-timeout/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/infinite-timeout/tests/utilities.py | 2 +- .../no-custom-config/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/no-custom-config/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../pydantic-extra-fields/tests/utilities.py | 2 +- .../pydantic-v1/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/pydantic-v1/tests/utilities.py | 2 +- .../union-utils/src/seed/core/http_client.py | 11 ++++++++--- .../exhaustive/union-utils/tests/utilities.py | 2 +- seed/python-sdk/extends/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/extends/tests/utilities.py | 2 +- .../file-download/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/file-download/tests/utilities.py | 2 +- .../file-upload/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/file-upload/tests/utilities.py | 2 +- seed/python-sdk/folders/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/folders/tests/utilities.py | 2 +- .../idempotency-headers/src/seed/core/http_client.py | 11 ++++++++--- .../python-sdk/idempotency-headers/tests/utilities.py | 2 +- seed/python-sdk/imdb/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/imdb/tests/utilities.py | 2 +- seed/python-sdk/literal/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/literal/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../multi-url-environment/tests/utilities.py | 2 +- .../no-environment/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/no-environment/tests/utilities.py | 2 +- seed/python-sdk/object/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/object/tests/utilities.py | 2 +- .../objects-with-imports/src/seed/core/http_client.py | 11 ++++++++--- .../objects-with-imports/tests/utilities.py | 2 +- seed/python-sdk/optional/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/optional/tests/utilities.py | 2 +- .../package-yml/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/package-yml/tests/utilities.py | 2 +- .../plain-text/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/plain-text/tests/utilities.py | 2 +- .../query-parameters/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/query-parameters/tests/utilities.py | 2 +- .../reserved-keywords/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/reserved-keywords/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../single-url-environment-default/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../tests/utilities.py | 2 +- .../python-sdk/streaming/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/streaming/tests/utilities.py | 2 +- seed/python-sdk/trace/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/trace/tests/utilities.py | 2 +- .../src/seed/core/http_client.py | 11 ++++++++--- .../undiscriminated-unions/tests/utilities.py | 2 +- seed/python-sdk/unions/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/unions/tests/utilities.py | 2 +- seed/python-sdk/unknown/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/unknown/tests/utilities.py | 2 +- .../python-sdk/variables/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/variables/tests/utilities.py | 2 +- .../python-sdk/websocket/src/seed/core/http_client.py | 11 ++++++++--- seed/python-sdk/websocket/tests/utilities.py | 2 +- 100 files changed, 446 insertions(+), 197 deletions(-) diff --git a/generators/python/core_utilities/sdk/http_client.py b/generators/python/core_utilities/sdk/http_client.py index c85e458d776..680f5ca00d8 100644 --- a/generators/python/core_utilities/sdk/http_client.py +++ b/generators/python/core_utilities/sdk/http_client.py @@ -3,6 +3,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -96,8 +97,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -116,8 +119,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/generators/python/sdk/CHANGELOG.md b/generators/python/sdk/CHANGELOG.md index e7ded3aad08..182bf10f7b9 100644 --- a/generators/python/sdk/CHANGELOG.md +++ b/generators/python/sdk/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.12.1] - 2024-03-18 + +- Fix: Fix the returned type and value contained within the retrying wrapper for the HTTPX client (http_client.py). + ## [0.12.1] - 2024-03-14 - Improves example generation and snippets for union types, as well as multi-url environments. diff --git a/generators/python/sdk/VERSION b/generators/python/sdk/VERSION index c1767fa8817..26acbf080be 100644 --- a/generators/python/sdk/VERSION +++ b/generators/python/sdk/VERSION @@ -1 +1 @@ -0.12.2-rc1 +0.12.2 diff --git a/seed/python-sdk/alias/src/seed/core/http_client.py b/seed/python-sdk/alias/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/alias/src/seed/core/http_client.py +++ b/seed/python-sdk/alias/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/alias/tests/utilities.py b/seed/python-sdk/alias/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/alias/tests/utilities.py +++ b/seed/python-sdk/alias/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/http_client.py b/seed/python-sdk/api-wide-base-path/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/http_client.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/api-wide-base-path/tests/utilities.py b/seed/python-sdk/api-wide-base-path/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utilities.py +++ b/seed/python-sdk/api-wide-base-path/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/audiences/src/seed/core/http_client.py b/seed/python-sdk/audiences/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/audiences/src/seed/core/http_client.py +++ b/seed/python-sdk/audiences/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/audiences/tests/utilities.py b/seed/python-sdk/audiences/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/audiences/tests/utilities.py +++ b/seed/python-sdk/audiences/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/http_client.py b/seed/python-sdk/auth-environment-variables/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/http_client.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/auth-environment-variables/tests/utilities.py b/seed/python-sdk/auth-environment-variables/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utilities.py +++ b/seed/python-sdk/auth-environment-variables/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/basic-auth/src/seed/core/http_client.py b/seed/python-sdk/basic-auth/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/http_client.py +++ b/seed/python-sdk/basic-auth/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/basic-auth/tests/utilities.py b/seed/python-sdk/basic-auth/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/basic-auth/tests/utilities.py +++ b/seed/python-sdk/basic-auth/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/http_client.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/http_client.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utilities.py b/seed/python-sdk/bearer-token-environment-variable/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utilities.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/bytes/src/seed/core/http_client.py b/seed/python-sdk/bytes/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/bytes/src/seed/core/http_client.py +++ b/seed/python-sdk/bytes/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/bytes/tests/utilities.py b/seed/python-sdk/bytes/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/bytes/tests/utilities.py +++ b/seed/python-sdk/bytes/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/circular-references/src/seed/core/http_client.py b/seed/python-sdk/circular-references/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/circular-references/src/seed/core/http_client.py +++ b/seed/python-sdk/circular-references/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/circular-references/tests/utilities.py b/seed/python-sdk/circular-references/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/circular-references/tests/utilities.py +++ b/seed/python-sdk/circular-references/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/code-samples/src/seed/core/http_client.py b/seed/python-sdk/code-samples/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/code-samples/src/seed/core/http_client.py +++ b/seed/python-sdk/code-samples/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/code-samples/tests/utilities.py b/seed/python-sdk/code-samples/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/code-samples/tests/utilities.py +++ b/seed/python-sdk/code-samples/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/custom-auth/src/seed/core/http_client.py b/seed/python-sdk/custom-auth/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/http_client.py +++ b/seed/python-sdk/custom-auth/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/custom-auth/tests/utilities.py b/seed/python-sdk/custom-auth/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/custom-auth/tests/utilities.py +++ b/seed/python-sdk/custom-auth/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/http_client.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/http_client.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/enum/no-custom-config/tests/utilities.py b/seed/python-sdk/enum/no-custom-config/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utilities.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/enum/strenum/src/seed/core/http_client.py b/seed/python-sdk/enum/strenum/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/http_client.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/enum/strenum/tests/utilities.py b/seed/python-sdk/enum/strenum/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/enum/strenum/tests/utilities.py +++ b/seed/python-sdk/enum/strenum/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/error-property/src/seed/core/http_client.py b/seed/python-sdk/error-property/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/error-property/src/seed/core/http_client.py +++ b/seed/python-sdk/error-property/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/error-property/tests/utilities.py b/seed/python-sdk/error-property/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/error-property/tests/utilities.py +++ b/seed/python-sdk/error-property/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/http_client.py b/seed/python-sdk/examples/client-filename/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/http_client.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/examples/client-filename/tests/utilities.py b/seed/python-sdk/examples/client-filename/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/examples/client-filename/tests/utilities.py +++ b/seed/python-sdk/examples/client-filename/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/http_client.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/http_client.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/examples/no-custom-config/tests/utilities.py b/seed/python-sdk/examples/no-custom-config/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utilities.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/additional_init_exports b/seed/python-sdk/exhaustive/additional_init_exports index 39ada5cccb1..02d2cd3d16a 160000 --- a/seed/python-sdk/exhaustive/additional_init_exports +++ b/seed/python-sdk/exhaustive/additional_init_exports @@ -1 +1 @@ -Subproject commit 39ada5cccb116c211d76966344a2da18c944def8 +Subproject commit 02d2cd3d16ac5741838a71ff990d7449fc05f767 diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utilities.py b/seed/python-sdk/exhaustive/improved_imports/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utilities.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/http_client.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/http_client.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utilities.py b/seed/python-sdk/exhaustive/union-utils/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/extends/src/seed/core/http_client.py b/seed/python-sdk/extends/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/extends/src/seed/core/http_client.py +++ b/seed/python-sdk/extends/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/extends/tests/utilities.py b/seed/python-sdk/extends/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/extends/tests/utilities.py +++ b/seed/python-sdk/extends/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/file-download/src/seed/core/http_client.py b/seed/python-sdk/file-download/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/file-download/src/seed/core/http_client.py +++ b/seed/python-sdk/file-download/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/file-download/tests/utilities.py b/seed/python-sdk/file-download/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/file-download/tests/utilities.py +++ b/seed/python-sdk/file-download/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/file-upload/src/seed/core/http_client.py b/seed/python-sdk/file-upload/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/file-upload/src/seed/core/http_client.py +++ b/seed/python-sdk/file-upload/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/file-upload/tests/utilities.py b/seed/python-sdk/file-upload/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/file-upload/tests/utilities.py +++ b/seed/python-sdk/file-upload/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/folders/src/seed/core/http_client.py b/seed/python-sdk/folders/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/folders/src/seed/core/http_client.py +++ b/seed/python-sdk/folders/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/folders/tests/utilities.py b/seed/python-sdk/folders/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/folders/tests/utilities.py +++ b/seed/python-sdk/folders/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/http_client.py b/seed/python-sdk/idempotency-headers/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/http_client.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/idempotency-headers/tests/utilities.py b/seed/python-sdk/idempotency-headers/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/idempotency-headers/tests/utilities.py +++ b/seed/python-sdk/idempotency-headers/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/imdb/src/seed/core/http_client.py b/seed/python-sdk/imdb/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/imdb/src/seed/core/http_client.py +++ b/seed/python-sdk/imdb/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/imdb/tests/utilities.py b/seed/python-sdk/imdb/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/imdb/tests/utilities.py +++ b/seed/python-sdk/imdb/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/literal/src/seed/core/http_client.py b/seed/python-sdk/literal/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/literal/src/seed/core/http_client.py +++ b/seed/python-sdk/literal/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/literal/tests/utilities.py b/seed/python-sdk/literal/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/literal/tests/utilities.py +++ b/seed/python-sdk/literal/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/http_client.py b/seed/python-sdk/multi-url-environment/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/http_client.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/multi-url-environment/tests/utilities.py b/seed/python-sdk/multi-url-environment/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/multi-url-environment/tests/utilities.py +++ b/seed/python-sdk/multi-url-environment/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/no-environment/src/seed/core/http_client.py b/seed/python-sdk/no-environment/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/no-environment/src/seed/core/http_client.py +++ b/seed/python-sdk/no-environment/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/no-environment/tests/utilities.py b/seed/python-sdk/no-environment/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/no-environment/tests/utilities.py +++ b/seed/python-sdk/no-environment/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/object/src/seed/core/http_client.py b/seed/python-sdk/object/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/object/src/seed/core/http_client.py +++ b/seed/python-sdk/object/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/object/tests/utilities.py b/seed/python-sdk/object/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/object/tests/utilities.py +++ b/seed/python-sdk/object/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/http_client.py b/seed/python-sdk/objects-with-imports/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/http_client.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/objects-with-imports/tests/utilities.py b/seed/python-sdk/objects-with-imports/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/objects-with-imports/tests/utilities.py +++ b/seed/python-sdk/objects-with-imports/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/optional/src/seed/core/http_client.py b/seed/python-sdk/optional/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/optional/src/seed/core/http_client.py +++ b/seed/python-sdk/optional/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/optional/tests/utilities.py b/seed/python-sdk/optional/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/optional/tests/utilities.py +++ b/seed/python-sdk/optional/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/package-yml/src/seed/core/http_client.py b/seed/python-sdk/package-yml/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/package-yml/src/seed/core/http_client.py +++ b/seed/python-sdk/package-yml/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/package-yml/tests/utilities.py b/seed/python-sdk/package-yml/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/package-yml/tests/utilities.py +++ b/seed/python-sdk/package-yml/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/plain-text/src/seed/core/http_client.py b/seed/python-sdk/plain-text/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/plain-text/src/seed/core/http_client.py +++ b/seed/python-sdk/plain-text/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/plain-text/tests/utilities.py b/seed/python-sdk/plain-text/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/plain-text/tests/utilities.py +++ b/seed/python-sdk/plain-text/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/query-parameters/src/seed/core/http_client.py b/seed/python-sdk/query-parameters/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/http_client.py +++ b/seed/python-sdk/query-parameters/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/query-parameters/tests/utilities.py b/seed/python-sdk/query-parameters/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/query-parameters/tests/utilities.py +++ b/seed/python-sdk/query-parameters/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/http_client.py b/seed/python-sdk/reserved-keywords/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/http_client.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/reserved-keywords/tests/utilities.py b/seed/python-sdk/reserved-keywords/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/reserved-keywords/tests/utilities.py +++ b/seed/python-sdk/reserved-keywords/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/http_client.py b/seed/python-sdk/single-url-environment-default/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/http_client.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/single-url-environment-default/tests/utilities.py b/seed/python-sdk/single-url-environment-default/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utilities.py +++ b/seed/python-sdk/single-url-environment-default/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/http_client.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/http_client.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utilities.py b/seed/python-sdk/single-url-environment-no-default/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/streaming/src/seed/core/http_client.py b/seed/python-sdk/streaming/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/streaming/src/seed/core/http_client.py +++ b/seed/python-sdk/streaming/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/streaming/tests/utilities.py b/seed/python-sdk/streaming/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/streaming/tests/utilities.py +++ b/seed/python-sdk/streaming/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/trace/src/seed/core/http_client.py b/seed/python-sdk/trace/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/trace/src/seed/core/http_client.py +++ b/seed/python-sdk/trace/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/trace/tests/utilities.py b/seed/python-sdk/trace/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/trace/tests/utilities.py +++ b/seed/python-sdk/trace/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/http_client.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/http_client.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/undiscriminated-unions/tests/utilities.py b/seed/python-sdk/undiscriminated-unions/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utilities.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/unions/src/seed/core/http_client.py b/seed/python-sdk/unions/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/unions/src/seed/core/http_client.py +++ b/seed/python-sdk/unions/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/unions/tests/utilities.py b/seed/python-sdk/unions/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/unions/tests/utilities.py +++ b/seed/python-sdk/unions/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/unknown/src/seed/core/http_client.py b/seed/python-sdk/unknown/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/unknown/src/seed/core/http_client.py +++ b/seed/python-sdk/unknown/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/unknown/tests/utilities.py b/seed/python-sdk/unknown/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/unknown/tests/utilities.py +++ b/seed/python-sdk/unknown/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/variables/src/seed/core/http_client.py b/seed/python-sdk/variables/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/variables/src/seed/core/http_client.py +++ b/seed/python-sdk/variables/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/variables/tests/utilities.py b/seed/python-sdk/variables/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/variables/tests/utilities.py +++ b/seed/python-sdk/variables/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate": diff --git a/seed/python-sdk/websocket/src/seed/core/http_client.py b/seed/python-sdk/websocket/src/seed/core/http_client.py index fbbbc15ec74..4e6877df257 100644 --- a/seed/python-sdk/websocket/src/seed/core/http_client.py +++ b/seed/python-sdk/websocket/src/seed/core/http_client.py @@ -5,6 +5,7 @@ import re import time import typing +from contextlib import asynccontextmanager, contextmanager from functools import wraps from random import random @@ -98,8 +99,10 @@ def request( return response @wraps(httpx.Client.stream) + @contextmanager def stream(self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream class AsyncHttpClient: @@ -118,8 +121,10 @@ async def request( return await self.request(max_retries=max_retries, retries=retries + 1, *args, **kwargs) return response - @wraps(httpx.AsyncClient.request) + @wraps(httpx.AsyncClient.stream) + @asynccontextmanager async def stream( self, *args: typing.Any, max_retries: int = 0, retries: int = 0, **kwargs: typing.Any ) -> typing.Any: - return self.httpx_client.stream(*args, **kwargs) + async with self.httpx_client.stream(*args, **kwargs) as stream: + yield stream diff --git a/seed/python-sdk/websocket/tests/utilities.py b/seed/python-sdk/websocket/tests/utilities.py index 46c89dce62b..59ec9e36d89 100644 --- a/seed/python-sdk/websocket/tests/utilities.py +++ b/seed/python-sdk/websocket/tests/utilities.py @@ -68,7 +68,7 @@ def validate_field(response: typing.Any, json_expectation: typing.Any, type_expe ) -# type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types +# Arg type_expectations is a deeply nested structure that matches the response, but with the values replaced with the expected types def validate_response(response: typing.Any, json_expectation: typing.Any, type_expectations: typing.Any) -> None: # Allow for an escape hatch if the object cannot be validated if type_expectations == "no_validate":