Skip to content

Commit e053fc4

Browse files
committed
fix: resolve ruff lint findings surfaced by CI
The old CI only checked black/isort formatting, never flake8, so these pre-existing issues were never enforced. Now that the format job runs `ruff check`, fix them: - loader: drop redundant lxml XMLSyntaxError import (zeep's is used) - proxy/signature: use `is`/`is not` for type and None comparisons - complex: `type(element) is list` (NOT isinstance -- Sequence subclasses list and would be double-wrapped) - builtins: remove unused `math` import - xsd/__init__: explicit re-export aliases for Nil/SkipValue - tests: drop unused vars, fix `== True`, detab XSD fixtures, strip trailing whitespace
1 parent db2424b commit e053fc4

10 files changed

Lines changed: 30 additions & 34 deletions

File tree

‎src/zeep/loader.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from urllib.parse import urljoin, urlparse, urlunparse
44

55
from lxml import etree
6-
from lxml.etree import Resolver, XMLParser, XMLSyntaxError, fromstring
6+
from lxml.etree import Resolver, XMLParser, fromstring
77

88
from zeep.exceptions import (
99
DTDForbidden,

‎src/zeep/proxy.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _merge_soap_headers(self, operation_soap_headers):
2020
# Merge the default _soapheaders with the passed _soapheaders
2121
if default_headers and operation_soap_headers:
2222
merged = copy.deepcopy(default_headers)
23-
if type(merged) != type(operation_soap_headers):
23+
if type(merged) is not type(operation_soap_headers):
2424
raise ValueError("Incompatible soapheaders definition")
2525

2626
if isinstance(operation_soap_headers, list):

‎src/zeep/wsse/signature.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def _signature_prepare(envelope, key, signature_method, digest_method):
244244
ctx.key = key
245245
_sign_node(ctx, signature, envelope.find(QName(soap_env, "Body")), digest_method)
246246
timestamp = security.find(QName(ns.WSU, "Timestamp"))
247-
if timestamp != None:
247+
if timestamp is not None:
248248
_sign_node(ctx, signature, timestamp, digest_method)
249249
ctx.sign(signature)
250250

‎src/zeep/xsd/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
55
"""
66

7-
from zeep.xsd.const import Nil, SkipValue
7+
from zeep.xsd.const import Nil as Nil
8+
from zeep.xsd.const import SkipValue as SkipValue
89
from zeep.xsd.elements import * # noqa
910
from zeep.xsd.schema import Schema as Schema
1011
from zeep.xsd.types import * # noqa

‎src/zeep/xsd/types/builtins.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import base64
22
import datetime
3-
import math
43
import re
54
from decimal import Decimal as _Decimal
65

‎src/zeep/xsd/types/complex.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(
5252
qname=None,
5353
is_global: bool = False,
5454
):
55-
if element and type(element) == list:
55+
if element and type(element) is list:
5656
element = Sequence(element)
5757

5858
self.name = self.__class__.__name__ if qname else None

‎tests/test_wsdl.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,9 +1263,7 @@ def test_import_cyclic():
12631263
transport.bind("https://tests.python-zeep.org/a.xsd", node_a)
12641264
transport.bind("https://tests.python-zeep.org/b.xsd", node_b)
12651265

1266-
document = wsdl.Document(
1267-
wsdl_content, transport, "https://tests.python-zeep.org/content.wsdl"
1268-
)
1266+
wsdl.Document(wsdl_content, transport, "https://tests.python-zeep.org/content.wsdl")
12691267

12701268

12711269
def test_import_no_location():
@@ -1309,6 +1307,4 @@ def test_import_no_location():
13091307
transport = DummyTransport()
13101308
transport.bind("https://tests.python-zeep.org/a.xsd", node_a)
13111309

1312-
document = wsdl.Document(
1313-
wsdl_content, transport, "https://tests.python-zeep.org/content.wsdl"
1314-
)
1310+
wsdl.Document(wsdl_content, transport, "https://tests.python-zeep.org/content.wsdl")

‎tests/test_wsdl_messages_document.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,9 +1329,9 @@ def test_deserialize_with_headers():
13291329
def test_deserialize_part_no_element():
13301330
wsdl_content = StringIO(
13311331
"""
1332-
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
1333-
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
1334-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
1332+
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
1333+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
1334+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
13351335
targetNamespace="http://tests.python-zeep.org/tns"
13361336
xmlns:tns="http://tests.python-zeep.org/tns">
13371337
<wsdl:types>

‎tests/test_xsd_parse.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,15 @@ def test_xsd_choice_with_references():
558558
<xsd:element name="el2" type="xsd:string"/>
559559
560560
<xsd:element name="container">
561-
<xsd:complexType>
562-
<xsd:sequence>
563-
<xsd:choice>
564-
<xsd:element ref="zeep:el1"/>
565-
<xsd:element ref="zeep:el2"/>
566-
<xsd:element name="el3" type="xsd:string"/>
567-
</xsd:choice>
568-
</xsd:sequence>
569-
</xsd:complexType>
561+
<xsd:complexType>
562+
<xsd:sequence>
563+
<xsd:choice>
564+
<xsd:element ref="zeep:el1"/>
565+
<xsd:element ref="zeep:el2"/>
566+
<xsd:element name="el3" type="xsd:string"/>
567+
</xsd:choice>
568+
</xsd:sequence>
569+
</xsd:complexType>
570570
</xsd:element>
571571
572572
</xsd:schema>

‎tests/test_xsd_visitor.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,15 @@ def test_referenced_elements_in_choice():
655655
<xsd:element name="el2" type="xsd:string"/>
656656
657657
<xsd:element name="container">
658-
<xsd:complexType>
659-
<xsd:sequence>
660-
<xsd:choice>
661-
<xsd:element ref="zeep:el1"/>
662-
<xsd:element ref="zeep:el2"/>
663-
<xsd:element name="el3" type="xsd:string"/>
664-
</xsd:choice>
665-
</xsd:sequence>
666-
</xsd:complexType>
658+
<xsd:complexType>
659+
<xsd:sequence>
660+
<xsd:choice>
661+
<xsd:element ref="zeep:el1"/>
662+
<xsd:element ref="zeep:el2"/>
663+
<xsd:element name="el3" type="xsd:string"/>
664+
</xsd:choice>
665+
</xsd:sequence>
666+
</xsd:complexType>
667667
</xsd:element>
668668
669669
</xsd:schema>
@@ -674,4 +674,4 @@ def test_referenced_elements_in_choice():
674674
for el_name, sub_element in container_element.type.elements:
675675
assert el_name in ("el1", "el2", "el3")
676676
assert sub_element.min_occurs == 0
677-
assert sub_element.is_optional == True
677+
assert sub_element.is_optional

0 commit comments

Comments
 (0)