summaryrefslogtreecommitdiff
blob: 368dca71ad387cffc7602d8f827c90d2b0d3016f (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
From 25701f0b69ee46914179070b7e8906ea3e521480 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Thu, 11 Nov 2021 08:55:41 +0100
Subject: [PATCH] Use stdlib functools.cached_property if available

Python 3.8+ provides a functools.cached_property in the stdlib that is
thread-safe, i.e. equivalent to threaded_cached_property.  Use it
instead of adding third-party dependencies whenever available.
---
 setup.py                            | 2 +-
 src/zeep/wsdl/attachments.py        | 6 +++++-
 src/zeep/xsd/elements/indicators.py | 6 +++++-
 src/zeep/xsd/types/any.py           | 6 +++++-
 src/zeep/xsd/types/complex.py       | 6 +++++-
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/setup.py b/setup.py
index cb51ac4..8ef81b6 100755
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup
 
 install_requires = [
     "attrs>=17.2.0",
-    "cached-property>=1.3.0",
+    "cached-property>=1.3.0; python_version<'3.8'",
     "isodate>=0.5.4",
     "lxml>=4.6.0",
     "platformdirs>=1.4.0",
diff --git a/src/zeep/wsdl/attachments.py b/src/zeep/wsdl/attachments.py
index 037e439..075bee5 100644
--- a/src/zeep/wsdl/attachments.py
+++ b/src/zeep/wsdl/attachments.py
@@ -6,7 +6,11 @@ See https://www.w3.org/TR/SOAP-attachments
 
 import base64
 
-from cached_property import cached_property
+try:
+    from functools import cached_property
+except ImportError:
+    from cached_property import cached_property
+
 from requests.structures import CaseInsensitiveDict
 
 
diff --git a/src/zeep/xsd/elements/indicators.py b/src/zeep/xsd/elements/indicators.py
index 40325da..e9ef2c4 100644
--- a/src/zeep/xsd/elements/indicators.py
+++ b/src/zeep/xsd/elements/indicators.py
@@ -16,7 +16,11 @@ import operator
 import typing
 from collections import OrderedDict, defaultdict, deque
 
-from cached_property import threaded_cached_property
+try:
+    from functools import cached_property as threaded_cached_property
+except ImportError:
+    from cached_property import threaded_cached_property
+
 from lxml import etree
 
 from zeep.exceptions import UnexpectedElementError, ValidationError
diff --git a/src/zeep/xsd/types/any.py b/src/zeep/xsd/types/any.py
index b4525e4..17f244e 100644
--- a/src/zeep/xsd/types/any.py
+++ b/src/zeep/xsd/types/any.py
@@ -1,7 +1,11 @@
 import logging
 import typing
 
-from cached_property import threaded_cached_property
+try:
+    from functools import cached_property as threaded_cached_property
+except ImportError:
+    from cached_property import threaded_cached_property
+
 from lxml import etree
 
 from zeep.utils import qname_attr
diff --git a/src/zeep/xsd/types/complex.py b/src/zeep/xsd/types/complex.py
index 8141bc1..b2ed9bf 100644
--- a/src/zeep/xsd/types/complex.py
+++ b/src/zeep/xsd/types/complex.py
@@ -4,7 +4,11 @@ import typing
 from collections import OrderedDict, deque
 from itertools import chain
 
-from cached_property import threaded_cached_property
+try:
+    from functools import cached_property as threaded_cached_property
+except ImportError:
+    from cached_property import threaded_cached_property
+
 from lxml import etree
 
 from zeep.exceptions import UnexpectedElementError, XMLParseError
-- 
2.33.1