From bb7838a41a7e7bb1960e67b52f1079496e72fcdc Mon Sep 17 00:00:00 2001 From: mattgd Date: Mon, 13 Jan 2025 16:40:56 -0500 Subject: [PATCH 1/2] Don't overwrite transport by default so users can use proxies via environment variables. --- workos/utils/http_client.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/workos/utils/http_client.py b/workos/utils/http_client.py index bc8dd426..5dd878ab 100644 --- a/workos/utils/http_client.py +++ b/workos/utils/http_client.py @@ -38,7 +38,7 @@ def __init__( client_id: str, version: str, timeout: Optional[int] = None, - transport: Optional[httpx.BaseTransport] = httpx.HTTPTransport(), + transport: Optional[httpx.BaseTransport] = None, ) -> None: super().__init__( api_key=api_key, @@ -51,7 +51,9 @@ def __init__( base_url=base_url, timeout=timeout, follow_redirects=True, - transport=transport, + # Only pass the transport if a custom one is provided, otherwise let httpx use + # the default so we don't overwrite environment configurations like proxies + transport=transport if transport else None, ) def is_closed(self) -> bool: @@ -136,7 +138,7 @@ def __init__( client_id: str, version: str, timeout: Optional[int] = None, - transport: Optional[httpx.AsyncBaseTransport] = httpx.AsyncHTTPTransport(), + transport: Optional[httpx.AsyncBaseTransport] = None, ) -> None: super().__init__( base_url=base_url, @@ -149,7 +151,9 @@ def __init__( base_url=base_url, timeout=timeout, follow_redirects=True, - transport=transport, + # Only pass the transport if a custom one is provided, otherwise let httpx use + # the default so we don't overwrite environment configurations like proxies + transport=transport if transport else None, ) def is_closed(self) -> bool: From 422152a7209d968afaf195f790ecc4d13505bd7a Mon Sep 17 00:00:00 2001 From: mattgd Date: Mon, 13 Jan 2025 16:50:31 -0500 Subject: [PATCH 2/2] Simplify. --- workos/utils/http_client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/workos/utils/http_client.py b/workos/utils/http_client.py index 5dd878ab..203c7df0 100644 --- a/workos/utils/http_client.py +++ b/workos/utils/http_client.py @@ -38,6 +38,8 @@ def __init__( client_id: str, version: str, timeout: Optional[int] = None, + # If no custom transport is provided, let httpx use the default + # so we don't overwrite environment configurations like proxies transport: Optional[httpx.BaseTransport] = None, ) -> None: super().__init__( @@ -51,9 +53,7 @@ def __init__( base_url=base_url, timeout=timeout, follow_redirects=True, - # Only pass the transport if a custom one is provided, otherwise let httpx use - # the default so we don't overwrite environment configurations like proxies - transport=transport if transport else None, + transport=transport, ) def is_closed(self) -> bool: @@ -138,6 +138,8 @@ def __init__( client_id: str, version: str, timeout: Optional[int] = None, + # If no custom transport is provided, let httpx use the default + # so we don't overwrite environment configurations like proxies transport: Optional[httpx.AsyncBaseTransport] = None, ) -> None: super().__init__( @@ -151,9 +153,7 @@ def __init__( base_url=base_url, timeout=timeout, follow_redirects=True, - # Only pass the transport if a custom one is provided, otherwise let httpx use - # the default so we don't overwrite environment configurations like proxies - transport=transport if transport else None, + transport=transport, ) def is_closed(self) -> bool: