Skip to content

Commit a64230e

Browse files
committed
Update docstrings to include return types for autocomplet
1 parent ca4c005 commit a64230e

File tree

3 files changed

+122
-15
lines changed

3 files changed

+122
-15
lines changed

Diff for: src/zeep/client.py

+43-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ def __init__(self, service_proxy, operation_name):
1515
self._op_name = operation_name
1616

1717
def __call__(self, *args, **kwargs):
18+
"""Call the operation with the given args and kwargs.
19+
20+
:rtype: zeep.xsd.CompoundValue
21+
22+
"""
23+
1824
if self._proxy._client._default_soapheaders:
1925
op_soapheaders = kwargs.get('_soapheaders')
2026
if op_soapheaders:
@@ -42,9 +48,19 @@ def __init__(self, client, binding, **binding_options):
4248
self._binding = binding
4349

4450
def __getattr__(self, key):
51+
"""Return the OperationProxy for the given key.
52+
53+
:rtype: OperationProxy
54+
55+
"""
4556
return self[key]
4657

4758
def __getitem__(self, key):
59+
"""Return the OperationProxy for the given key.
60+
61+
:rtype: OperationProxy
62+
63+
"""
4864
try:
4965
self._binding.get(key)
5066
except ValueError:
@@ -62,9 +78,19 @@ def __init__(self, types, kind, namespace):
6278
self._ns = types.get_ns_prefix(namespace)
6379

6480
def __getattr__(self, key):
81+
"""Return the complexType or simpleType for the given localname.
82+
83+
:rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType
84+
85+
"""
6586
return self[key]
6687

6788
def __getitem__(self, key):
89+
"""Return the complexType or simpleType for the given localname.
90+
91+
:rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType
92+
93+
"""
6894
return self._method('{%s}%s' % (self._ns, key))
6995

7096

@@ -102,7 +128,11 @@ def __init__(self, wsdl, wsse=None, transport=None,
102128

103129
@property
104130
def service(self):
105-
"""The default ServiceProxy instance"""
131+
"""The default ServiceProxy instance
132+
133+
:rtype: ServiceProxy
134+
135+
"""
106136
if self._default_service:
107137
return self._default_service
108138

@@ -182,15 +212,25 @@ def type_factory(self, namespace):
182212
factory = client.type_factory('ns0')
183213
user = factory.User(name='John')
184214
215+
:rtype: Factory
216+
185217
"""
186218
return Factory(self.wsdl.types, 'type', namespace)
187219

188220
def get_type(self, name):
189-
"""Return the type for the given qualified name."""
221+
"""Return the type for the given qualified name.
222+
223+
:rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType
224+
225+
"""
190226
return self.wsdl.types.get_type(name)
191227

192228
def get_element(self, name):
193-
"""Return the element for the given qualified name."""
229+
"""Return the element for the given qualified name.
230+
231+
:rtype: zeep.xsd.Element
232+
233+
"""
194234
return self.wsdl.types.get_element(name)
195235

196236
def set_ns_prefix(self, prefix, namespace):

Diff for: src/zeep/xsd/schema.py

+78-12
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ def namespaces(self):
6363

6464
@property
6565
def elements(self):
66-
"""Yield all globla xsd.Type objects"""
66+
"""Yield all globla xsd.Type objects
67+
68+
:rtype: Iterable of zeep.xsd.Element
69+
70+
"""
6771
for document in self.documents:
6872
for element in document._elements.values():
6973
yield element
7074

7175
@property
7276
def types(self):
73-
"""Yield all globla xsd.Type objects"""
77+
"""Yield all global xsd.Type objects
78+
79+
:rtype: Iterable of zeep.xsd.ComplexType
80+
81+
"""
7482
for document in self.documents:
7583
for type_ in document._types.values():
7684
yield type_
@@ -94,12 +102,20 @@ def add_documents(self, schema_nodes, location):
94102
self._prefix_map_auto = self._create_prefix_map()
95103

96104
def get_element(self, qname):
97-
"""Return a global xsd.Element object with the given qname"""
105+
"""Return a global xsd.Element object with the given qname
106+
107+
:rtype: zeep.xsd.Group
108+
109+
"""
98110
qname = self._create_qname(qname)
99111
return self._get_instance(qname, 'get_element', 'element')
100112

101113
def get_type(self, qname, fail_silently=False):
102-
"""Return a global xsd.Type object with the given qname"""
114+
"""Return a global xsd.Type object with the given qname
115+
116+
:rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType
117+
118+
"""
103119
qname = self._create_qname(qname)
104120
try:
105121
return self._get_instance(qname, 'get_type', 'type')
@@ -110,15 +126,27 @@ def get_type(self, qname, fail_silently=False):
110126
raise
111127

112128
def get_group(self, qname):
113-
"""Return a global xsd.Group object with the given qname"""
129+
"""Return a global xsd.Group object with the given qname.
130+
131+
:rtype: zeep.xsd.Group
132+
133+
"""
114134
return self._get_instance(qname, 'get_group', 'group')
115135

116136
def get_attribute(self, qname):
117-
"""Return a global xsd.attributeGroup object with the given qname"""
137+
"""Return a global xsd.attributeGroup object with the given qname
138+
139+
:rtype: zeep.xsd.Attribute
140+
141+
"""
118142
return self._get_instance(qname, 'get_attribute', 'attribute')
119143

120144
def get_attribute_group(self, qname):
121-
"""Return a global xsd.attributeGroup object with the given qname"""
145+
"""Return a global xsd.attributeGroup object with the given qname
146+
147+
:rtype: zeep.xsd.AttributeGroup
148+
149+
"""
122150
return self._get_instance(qname, 'get_attribute_group', 'attributeGroup')
123151

124152
def set_ns_prefix(self, prefix, namespace):
@@ -201,6 +229,8 @@ def _create_qname(self, name):
201229
202230
This also expands the shorthand notation.
203231
232+
:rtype: lxml.etree.QNaame
233+
204234
"""
205235
if isinstance(name, etree.QName):
206236
return name
@@ -231,6 +261,11 @@ def _create_prefix_map(self):
231261
return prefix_map
232262

233263
def _has_schema_document(self, namespace):
264+
"""Return a boolean if there is a SchemaDocumnet for the namespace.
265+
266+
:rtype: boolean
267+
268+
"""
234269
return namespace in self._documents
235270

236271
def _add_schema_document(self, document):
@@ -239,11 +274,22 @@ def _add_schema_document(self, document):
239274
documents.append(document)
240275

241276
def _get_schema_document(self, namespace, location):
277+
"""Return a list of SchemaDocument's for the given namespace AND
278+
location.
279+
280+
:rtype: SchemaDocument
281+
282+
"""
242283
for document in self._documents.get(namespace, []):
243284
if document._location == location:
244285
return document
245286

246287
def _get_schema_documents(self, namespace, fail_silently=False):
288+
"""Return a list of SchemaDocument's for the given namespace.
289+
290+
:rtype: list of SchemaDocument
291+
292+
"""
247293
if namespace not in self._documents:
248294
if fail_silently:
249295
return []
@@ -370,23 +416,43 @@ def register_attribute_group(self, name, value):
370416
self._attribute_groups[name] = value
371417

372418
def get_type(self, qname):
373-
"""Return a xsd.Type object from this schema"""
419+
"""Return a xsd.Type object from this schema
420+
421+
:rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType
422+
423+
"""
374424
return self._get_instance(qname, self._types, 'type')
375425

376426
def get_element(self, qname):
377-
"""Return a xsd.Element object from this schema"""
427+
"""Return a xsd.Element object from this schema
428+
429+
:rtype: zeep.xsd.Element
430+
431+
"""
378432
return self._get_instance(qname, self._elements, 'element')
379433

380434
def get_group(self, qname):
381-
"""Return a xsd.Group object from this schema"""
435+
"""Return a xsd.Group object from this schema.
436+
437+
:rtype: zeep.xsd.Group
438+
439+
"""
382440
return self._get_instance(qname, self._groups, 'group')
383441

384442
def get_attribute(self, qname):
385-
"""Return a xsd.Attribute object from this schema"""
443+
"""Return a xsd.Attribute object from this schema
444+
445+
:rtype: zeep.xsd.Attribute
446+
447+
"""
386448
return self._get_instance(qname, self._attributes, 'attribute')
387449

388450
def get_attribute_group(self, qname):
389-
"""Return a xsd.AttributeGroup object from this schema"""
451+
"""Return a xsd.AttributeGroup object from this schema
452+
453+
:rtype: zeep.xsd.AttributeGroup
454+
455+
"""
390456
return self._get_instance(qname, self._attribute_groups, 'attributeGroup')
391457

392458
def _get_instance(self, qname, items, item_name):

Diff for: src/zeep/xsd/valueobjects.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def xsd_elm(self):
3434

3535

3636
class CompoundValue(object):
37+
"""Represents a data object for a specific xsd:complexType."""
3738

3839
def __init__(self, *args, **kwargs):
3940
values = OrderedDict()

0 commit comments

Comments
 (0)