Skip to content

Commit fd2a5fa

Browse files
committed
Run make format
1 parent 3532651 commit fd2a5fa

File tree

9 files changed

+52
-37
lines changed

9 files changed

+52
-37
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ coverage:
2323
pytest --cov=zeep --cov-report=term-missing --cov-report=html
2424

2525
format:
26-
isort --recursive src tests setup.py
26+
isort src tests setup.py
2727
black src/ tests/ setup.py
2828

2929
docs:

Diff for: src/zeep/client.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import typing
33

4-
from zeep.proxy import ServiceProxy, AsyncServiceProxy
4+
from zeep.proxy import AsyncServiceProxy, ServiceProxy
55
from zeep.settings import Settings
66
from zeep.transports import AsyncTransport, Transport
77
from zeep.wsdl import Document
@@ -50,6 +50,7 @@ class Client:
5050
:param settings: a zeep.Settings() object
5151
5252
"""
53+
5354
_default_transport = Transport
5455

5556
def __init__(
@@ -66,7 +67,9 @@ def __init__(
6667
raise ValueError("No URL given for the wsdl")
6768

6869
self.settings = settings or Settings()
69-
self.transport = transport if transport is not None else self._default_transport()
70+
self.transport = (
71+
transport if transport is not None else self._default_transport()
72+
)
7073
self.wsdl = Document(wsdl, self.transport, settings=self.settings)
7174
self.wsse = wsse
7275
self.plugins = plugins if plugins is not None else []

Diff for: src/zeep/proxy.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __call__(self, *args, **kwargs):
4141
"""
4242
soap_headers = self._merge_soap_headers(kwargs.get("_soapheaders"))
4343
if soap_headers:
44-
kwargs['_soapheaders'] = soap_headers
44+
kwargs["_soapheaders"] = soap_headers
4545

4646
return self._proxy._binding.send(
4747
self._proxy._client,
@@ -53,14 +53,13 @@ def __call__(self, *args, **kwargs):
5353

5454

5555
class AsyncOperationProxy(OperationProxy):
56-
5756
async def __call__(self, *args, **kwargs):
5857
"""Call the operation with the given args and kwargs.
5958
6059
:rtype: zeep.xsd.CompoundValue
6160
6261
"""
63-
kwargs['_soapheaders'] = self._merge_soap_headers(kwargs.get("_soapheaders"))
62+
kwargs["_soapheaders"] = self._merge_soap_headers(kwargs.get("_soapheaders"))
6463

6564
return await self._proxy._binding.send_async(
6665
self._proxy._client,

Diff for: src/zeep/wsdl/wsdl.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
from lxml import etree
1616

1717
from zeep.exceptions import IncompleteMessage
18-
from zeep.loader import absolute_location, is_relative_path, load_external, load_external_async
18+
from zeep.loader import (
19+
absolute_location,
20+
is_relative_path,
21+
load_external,
22+
load_external_async,
23+
)
1924
from zeep.settings import Settings
2025
from zeep.utils import findall_multiple_ns
2126
from zeep.wsdl import parse
@@ -156,7 +161,6 @@ def _add_definition(self, definition: "Definition"):
156161
self._definitions[key] = definition
157162

158163

159-
160164
class Definition:
161165
"""The Definition represents one wsdl:definition within a Document.
162166

Diff for: src/zeep/wsse/username.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ def __init__(
5252
zulu_timestamp=None,
5353
hash_password=None,
5454
):
55-
'''
55+
"""
5656
Some SOAP services want zulu timestamps with Z in timestamps and
5757
in password digests they may want password to be hashed before
5858
adding it to nonce and created.
59-
'''
59+
"""
6060
self.username = username
6161
self.password = password
6262
self.password_digest = password_digest
@@ -67,7 +67,6 @@ def __init__(
6767
self.zulu_timestamp = zulu_timestamp
6868
self.hash_password = hash_password
6969

70-
7170
def apply(self, envelope, headers):
7271
security = utils.get_security_header(envelope)
7372

@@ -117,7 +116,9 @@ def _create_password_digest(self):
117116
# digest = Base64 ( SHA-1 ( nonce + created + password ) )
118117
if not self.password_digest and self.hash_password:
119118
digest = base64.b64encode(
120-
hashlib.sha1(nonce + timestamp.encode("utf-8") + hashlib.sha1(password).digest()).digest()
119+
hashlib.sha1(
120+
nonce + timestamp.encode("utf-8") + hashlib.sha1(password).digest()
121+
).digest()
121122
).decode("ascii")
122123
elif not self.password_digest:
123124
digest = base64.b64encode(

Diff for: src/zeep/xsd/types/builtins.py

+21-19
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ def _treat_whitespace(func):
3939
def _wrapper(self, value):
4040
assert behaviour in ["replace", "collapse", "preserve"]
4141
if behaviour == "replace":
42-
return func(self, re.sub(r'[\n\r\t]', ' ', value))
42+
return func(self, re.sub(r"[\n\r\t]", " ", value))
4343
elif behaviour == "collapse":
44-
return func(self, re.sub(r'[\n\r\t ]', ' ', value).strip())
44+
return func(self, re.sub(r"[\n\r\t ]", " ", value).strip())
4545
return func(self, value)
46+
4647
return _wrapper
48+
4749
return _treat_whitespace
4850

4951

@@ -71,7 +73,7 @@ class Boolean(BuiltinType):
7173
def xmlvalue(self, value):
7274
return "true" if value and value not in ("false", "0") else "false"
7375

74-
@treat_whitespace('collapse')
76+
@treat_whitespace("collapse")
7577
def pythonvalue(self, value):
7678
"""Return True if the 'true' or '1'. 'false' and '0' are legal false
7779
values, but we consider everything not true as false.
@@ -88,7 +90,7 @@ class Decimal(BuiltinType):
8890
def xmlvalue(self, value):
8991
return str(value)
9092

91-
@treat_whitespace('collapse')
93+
@treat_whitespace("collapse")
9294
def pythonvalue(self, value):
9395
return _Decimal(value)
9496

@@ -100,7 +102,7 @@ class Float(BuiltinType):
100102
def xmlvalue(self, value):
101103
return str(value).upper()
102104

103-
@treat_whitespace('collapse')
105+
@treat_whitespace("collapse")
104106
def pythonvalue(self, value):
105107
return float(value)
106108

@@ -113,7 +115,7 @@ class Double(BuiltinType):
113115
def xmlvalue(self, value):
114116
return str(value)
115117

116-
@treat_whitespace('collapse')
118+
@treat_whitespace("collapse")
117119
def pythonvalue(self, value):
118120
return float(value)
119121

@@ -126,7 +128,7 @@ class Duration(BuiltinType):
126128
def xmlvalue(self, value):
127129
return isodate.duration_isoformat(value)
128130

129-
@treat_whitespace('collapse')
131+
@treat_whitespace("collapse")
130132
def pythonvalue(self, value):
131133
if value.startswith("PT-"):
132134
value = value.replace("PT-", "PT")
@@ -162,7 +164,7 @@ def xmlvalue(self, value):
162164
return isodate.isostrf.strftime(value, "%Y-%m-%dT%H:%M:%S.%f%Z")
163165
return isodate.isostrf.strftime(value, "%Y-%m-%dT%H:%M:%S%Z")
164166

165-
@treat_whitespace('collapse')
167+
@treat_whitespace("collapse")
166168
def pythonvalue(self, value):
167169

168170
# Determine based on the length of the value if it only contains a date
@@ -185,7 +187,7 @@ def xmlvalue(self, value):
185187
return isodate.isostrf.strftime(value, "%H:%M:%S.%f%Z")
186188
return isodate.isostrf.strftime(value, "%H:%M:%S%Z")
187189

188-
@treat_whitespace('collapse')
190+
@treat_whitespace("collapse")
189191
def pythonvalue(self, value):
190192
return isodate.parse_time(value)
191193

@@ -200,7 +202,7 @@ def xmlvalue(self, value):
200202
return value
201203
return isodate.isostrf.strftime(value, "%Y-%m-%d")
202204

203-
@treat_whitespace('collapse')
205+
@treat_whitespace("collapse")
204206
def pythonvalue(self, value):
205207
return isodate.parse_date(value)
206208

@@ -224,7 +226,7 @@ def xmlvalue(self, value):
224226
year, month, tzinfo = value
225227
return "%04d-%02d%s" % (year, month, _unparse_timezone(tzinfo))
226228

227-
@treat_whitespace('collapse')
229+
@treat_whitespace("collapse")
228230
def pythonvalue(self, value):
229231
match = self._pattern.match(value)
230232
if not match:
@@ -253,7 +255,7 @@ def xmlvalue(self, value):
253255
year, tzinfo = value
254256
return "%04d%s" % (year, _unparse_timezone(tzinfo))
255257

256-
@treat_whitespace('collapse')
258+
@treat_whitespace("collapse")
257259
def pythonvalue(self, value):
258260
match = self._pattern.match(value)
259261
if not match:
@@ -281,7 +283,7 @@ def xmlvalue(self, value):
281283
month, day, tzinfo = value
282284
return "--%02d-%02d%s" % (month, day, _unparse_timezone(tzinfo))
283285

284-
@treat_whitespace('collapse')
286+
@treat_whitespace("collapse")
285287
def pythonvalue(self, value):
286288
match = self._pattern.match(value)
287289
if not match:
@@ -312,7 +314,7 @@ def xmlvalue(self, value):
312314
day, tzinfo = value
313315
return "---%02d%s" % (day, _unparse_timezone(tzinfo))
314316

315-
@treat_whitespace('collapse')
317+
@treat_whitespace("collapse")
316318
def pythonvalue(self, value):
317319
match = self._pattern.match(value)
318320
if not match:
@@ -337,7 +339,7 @@ def xmlvalue(self, value):
337339
month, tzinfo = value
338340
return "--%d%s" % (month, _unparse_timezone(tzinfo))
339341

340-
@treat_whitespace('collapse')
342+
@treat_whitespace("collapse")
341343
def pythonvalue(self, value):
342344
match = self._pattern.match(value)
343345
if not match:
@@ -378,7 +380,7 @@ class AnyURI(BuiltinType):
378380
def xmlvalue(self, value):
379381
return value
380382

381-
@treat_whitespace('collapse')
383+
@treat_whitespace("collapse")
382384
def pythonvalue(self, value):
383385
return value
384386

@@ -391,7 +393,7 @@ class QName(BuiltinType):
391393
def xmlvalue(self, value):
392394
return value
393395

394-
@treat_whitespace('collapse')
396+
@treat_whitespace("collapse")
395397
def pythonvalue(self, value):
396398
return value
397399

@@ -408,15 +410,15 @@ class Notation(BuiltinType):
408410
class NormalizedString(String):
409411
_default_qname = xsd_ns("normalizedString")
410412

411-
@treat_whitespace('replace')
413+
@treat_whitespace("replace")
412414
def pythonvalue(self, value):
413415
return value
414416

415417

416418
class Token(NormalizedString):
417419
_default_qname = xsd_ns("token")
418420

419-
@treat_whitespace('collapse')
421+
@treat_whitespace("collapse")
420422
def pythonvalue(self, value):
421423
return value
422424

Diff for: src/zeep/xsd/types/collection.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from zeep.xsd.types.simple import AnySimpleType
88

99
if typing.TYPE_CHECKING:
10+
from zeep.xsd.schema import Schema
1011
from zeep.xsd.types.base import Type
1112
from zeep.xsd.types.complex import ComplexType
1213
from zeep.xsd.valueobjects import CompoundValue
13-
from zeep.xsd.schema import Schema
1414

1515
__all__ = ["ListType", "UnionType"]
1616

@@ -80,7 +80,9 @@ def parse_xmlelement(
8080
allow_none: bool = True,
8181
context: XmlParserContext = None,
8282
schema_type: "Type" = None,
83-
) -> typing.Optional[typing.Union[str, "CompoundValue", typing.List[etree._Element]]]:
83+
) -> typing.Optional[
84+
typing.Union[str, "CompoundValue", typing.List[etree._Element]]
85+
]:
8486
if self.item_class:
8587
return self.item_class().parse_xmlelement(
8688
xmlelement, schema, allow_none, context

Diff for: tests/test_async_transport.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
from pretend import stub
66
from pytest_httpx import HTTPXMock
77

8-
98
from zeep import exceptions
10-
from zeep.transports import AsyncTransport
119
from zeep.cache import InMemoryCache
10+
from zeep.transports import AsyncTransport
1211

1312

1413
@pytest.mark.requests
@@ -69,7 +68,9 @@ async def test_session_close(httpx_mock: HTTPXMock):
6968
async def test_http_error(httpx_mock: HTTPXMock):
7069
transport = AsyncTransport()
7170

72-
httpx_mock.add_response(url="http://tests.python-zeep.org/test.xml", data="x", status_code=500)
71+
httpx_mock.add_response(
72+
url="http://tests.python-zeep.org/test.xml", data="x", status_code=500
73+
)
7374
with pytest.raises(exceptions.TransportError) as exc:
7475
transport.load("http://tests.python-zeep.org/test.xml")
7576
assert exc.value.status_code == 500

Diff for: tests/test_xsd_builtins.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ def test_pythonvalue(self):
280280
assert instance.pythonvalue("2001+00:00") == (2001, pytz.utc)
281281
assert instance.pythonvalue("-2001") == (-2001, None)
282282
assert instance.pythonvalue("-20000") == (-20000, None)
283-
assert instance.pythonvalue(" \t2001+02:00\r\n ") == (2001, pytz.FixedOffset(120))
283+
assert instance.pythonvalue(" \t2001+02:00\r\n ") == (
284+
2001,
285+
pytz.FixedOffset(120),
286+
)
284287

285288
with pytest.raises(builtins.ParseError):
286289
assert instance.pythonvalue("99")

0 commit comments

Comments
 (0)