summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/zeep/httpx-compat.patch
blob: 930ab5c10ac37f7221d3f1fc28d0f958c8e8cde3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
From 4e2568574271e5e37de5e5c86e4bb12a5e661c6b Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Wed, 4 Dec 2024 16:34:22 -0600
Subject: [PATCH 1/3] Update proxy argument in httpx Client/AsyncClient

Ref: https://github.com/encode/httpx/blob/master/CHANGELOG.md#0260-20th-december-2023
---
 src/zeep/transports.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index 2a1ee8bd..0cbb05f2 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -183,15 +183,17 @@ def __init__(
 
         self._close_session = False
         self.cache = cache
+        proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
+        proxy_kwargs = {proxy_kwarg_name: proxy}
         self.wsdl_client = wsdl_client or httpx.Client(
             verify=verify_ssl,
-            proxies=proxy,
             timeout=timeout,
+            **proxy_kwargs,
         )
         self.client = client or httpx.AsyncClient(
             verify=verify_ssl,
-            proxies=proxy,
             timeout=operation_timeout,
+            **proxy_kwargs,
         )
         self.logger = logging.getLogger(__name__)
 

From 411ea4ef7ec4d160dd2cb2d29288c9d34466f286 Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Sat, 14 Dec 2024 09:34:53 -0600
Subject: [PATCH 2/3] Correct httpx version comparison

---
 pyproject.toml         |  5 ++++-
 src/zeep/transports.py | 19 +++++++++++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index c151100a..414e83c2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,7 +53,10 @@ test = [
     "flake8-debugger==4.1.2",
     "flake8-imports==0.1.1",
 ]
-async = ["httpx>=0.15.0"]
+async = [
+    "httpx>=0.15.0",
+    "packaging",
+]
 xmlsec = ["xmlsec>=0.6.1"]
 
 [build-system]
diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index 0cbb05f2..f1b00565 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -16,6 +16,15 @@
 except ImportError:
     httpx = None
 
+try:
+    from packaging.version import Version
+    if Version(httpx.__version__) >= Version("0.26.0"):
+        HTTPX_PROXY_KWARG_NAME = "proxy"
+    else:
+        HTTPX_PROXY_KWARG_NAME = "proxies"
+except ImportError:
+    Version = None
+    HTTPX_PROXY_KWARG_NAME = None
 
 __all__ = ["AsyncTransport", "Transport"]
 
@@ -178,13 +187,15 @@ def __init__(
         verify_ssl=True,
         proxy=None,
     ):
-        if httpx is None:
-            raise RuntimeError("The AsyncTransport is based on the httpx module")
+        if httpx is None or HTTPX_PROXY_KWARG_NAME is None:
+            raise RuntimeError(
+                "To use AsyncTransport, install zeep with the async extras, "
+                "e.g., `pip install zeep[async]`"
+            )
 
         self._close_session = False
         self.cache = cache
-        proxy_kwarg_name = "proxy" if httpx.__version__ >= "0.26.0" else "proxies"
-        proxy_kwargs = {proxy_kwarg_name: proxy}
+        proxy_kwargs = {HTTPX_PROXY_KWARG_NAME: proxy}
         self.wsdl_client = wsdl_client or httpx.Client(
             verify=verify_ssl,
             timeout=timeout,

From c20b7ba21d815377cb5d5095eb9e9f5918fb678d Mon Sep 17 00:00:00 2001
From: aschollmeier-gcmlp <aschollmeier@gcmlp.com>
Date: Sat, 14 Dec 2024 10:00:17 -0600
Subject: [PATCH 3/3] Avoid potential AttributeError in httpx version check

---
 src/zeep/transports.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/zeep/transports.py b/src/zeep/transports.py
index f1b00565..d2136373 100644
--- a/src/zeep/transports.py
+++ b/src/zeep/transports.py
@@ -18,10 +18,10 @@
 
 try:
     from packaging.version import Version
-    if Version(httpx.__version__) >= Version("0.26.0"):
-        HTTPX_PROXY_KWARG_NAME = "proxy"
-    else:
+    if httpx is None or Version(httpx.__version__) < Version("0.26.0"):
         HTTPX_PROXY_KWARG_NAME = "proxies"
+    else:
+        HTTPX_PROXY_KWARG_NAME = "proxy"
 except ImportError:
     Version = None
     HTTPX_PROXY_KWARG_NAME = None