1From 4e2568574271e5e37de5e5c86e4bb12a5e661c6b Mon Sep 17 00:00:00 2001
2From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
3Date: Wed, 4 Dec 2024 16:34:22 -0600
4Subject: [PATCH 1/3] Update proxy argument in httpx Client/AsyncClient
5
6Ref: https://github.com/encode/httpx/blob/master/CHANGELOG.md#0260-20th-december-2023
7---
8 src/zeep/transports.py | 6 ++++--
9 1 file changed, 4 insertions(+), 2 deletions(-)
10
11diff --git a/src/zeep/transports.py b/src/zeep/transports.py
12index 2a1ee8bd..0cbb05f2 100644
13--- a/src/zeep/transports.py
14+++ b/src/zeep/transports.py
15@@ -183,15 +183,17 @@ def __init__(
16
17 self._close_session = False
18 self.cache = cache
19+ proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
20+ proxy_kwargs = {proxy_kwarg_name: proxy}
21 self.wsdl_client = wsdl_client or httpx.Client(
22 verify=verify_ssl,
23- proxies=proxy,
24 timeout=timeout,
25+ **proxy_kwargs,
26 )
27 self.client = client or httpx.AsyncClient(
28 verify=verify_ssl,
29- proxies=proxy,
30 timeout=operation_timeout,
31+ **proxy_kwargs,
32 )
33 self.logger = logging.getLogger(__name__)
34
35
36From 411ea4ef7ec4d160dd2cb2d29288c9d34466f286 Mon Sep 17 00:00:00 2001
37From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
38Date: Sat, 14 Dec 2024 09:34:53 -0600
39Subject: [PATCH 2/3] Correct httpx version comparison
40
41---
42 pyproject.toml | 5 ++++-
43 src/zeep/transports.py | 19 +++++++++++++++----
44 2 files changed, 19 insertions(+), 5 deletions(-)
45
46diff --git a/pyproject.toml b/pyproject.toml
47index c151100a..414e83c2 100644
48--- a/pyproject.toml
49+++ b/pyproject.toml
50@@ -53,7 +53,10 @@ test = [
51 "flake8-debugger==4.1.2",
52 "flake8-imports==0.1.1",
53 ]
54-async = ["httpx>=0.15.0"]
55+async = [
56+ "httpx>=0.15.0",
57+ "packaging",
58+]
59 xmlsec = ["xmlsec>=0.6.1"]
60
61 [build-system]
62diff --git a/src/zeep/transports.py b/src/zeep/transports.py
63index 0cbb05f2..f1b00565 100644
64--- a/src/zeep/transports.py
65+++ b/src/zeep/transports.py
66@@ -16,6 +16,15 @@
67 except ImportError:
68 httpx = None
69
70+try:
71+ from packaging.version import Version
72+ if Version(httpx.__version__) >= Version("0.26.0"):
73+ HTTPX_PROXY_KWARG_NAME = "proxy"
74+ else:
75+ HTTPX_PROXY_KWARG_NAME = "proxies"
76+except ImportError:
77+ Version = None
78+ HTTPX_PROXY_KWARG_NAME = None
79
80 __all__ = ["AsyncTransport", "Transport"]
81
82@@ -178,13 +187,15 @@ def __init__(
83 verify_ssl=True,
84 proxy=None,
85 ):
86- if httpx is None:
87- raise RuntimeError("The AsyncTransport is based on the httpx module")
88+ if httpx is None or HTTPX_PROXY_KWARG_NAME is None:
89+ raise RuntimeError(
90+ "To use AsyncTransport, install zeep with the async extras, "
91+ "e.g., `pip install zeep[async]`"
92+ )
93
94 self._close_session = False
95 self.cache = cache
96- proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
97- proxy_kwargs = {proxy_kwarg_name: proxy}
98+ proxy_kwargs = {HTTPX_PROXY_KWARG_NAME: proxy}
99 self.wsdl_client = wsdl_client or httpx.Client(
100 verify=verify_ssl,
101 timeout=timeout,
102
103From c20b7ba21d815377cb5d5095eb9e9f5918fb678d Mon Sep 17 00:00:00 2001
104From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
105Date: Sat, 14 Dec 2024 10:00:17 -0600
106Subject: [PATCH 3/3] Avoid potential AttributeError in httpx version check
107
108---
109 src/zeep/transports.py | 6 +++---
110 1 file changed, 3 insertions(+), 3 deletions(-)
111
112diff --git a/src/zeep/transports.py b/src/zeep/transports.py
113index f1b00565..d2136373 100644
114--- a/src/zeep/transports.py
115+++ b/src/zeep/transports.py
116@@ -18,10 +18,10 @@
117
118 try:
119 from packaging.version import Version
120- if Version(httpx.__version__) >= Version("0.26.0"):
121- HTTPX_PROXY_KWARG_NAME = "proxy"
122- else:
123+ if httpx is None or Version(httpx.__version__) < Version("0.26.0"):
124 HTTPX_PROXY_KWARG_NAME = "proxies"
125+ else:
126+ HTTPX_PROXY_KWARG_NAME = "proxy"
127 except ImportError:
128 Version = None
129 HTTPX_PROXY_KWARG_NAME = None