You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This leads to confusions as to how to treat the returned values and triggers mypy alerts.
Is it possible to somehow instrument the OperationProxy to always return e.g. CompundValue that could be unpacked manually later on if needed?
# Check if we can remove the wrapping object to make the return value
# easier to use.
result=next(iter(result.__values__.values()))
ifisinstance(result, xsd.CompoundValue):
children=result._xsd_type.elements
attributes=result._xsd_type.attributes
iflen(children) ==1andlen(attributes) ==0:
item_name, item_element=children[0]
retval=getattr(result, item_name)
returnretval
returnresult
"to make the return value easier to use" in this particular case makes things more different for the client:
client code has to know which attributes should be passed when calling zeep.proxy.OperationProxy. This knowledge could be obtained from the WSDL definition.
as a return value client code will receive either etree.Element or zeep.xsd.valueobjects.CompundValue
Seems fair enough to always return zeep.xsd.valueobjects.CompundValue so that the client will have to use its properties using the same WSDL definition as a source of truth about the response structure.
Activity
atatarn commentedon Aug 10, 2024
To be more specific:
python-zeep/src/zeep/wsdl/messages/soap.py
Lines 126 to 136 in 377d931
"to make the return value easier to use" in this particular case makes things more different for the client:
zeep.proxy.OperationProxy. This knowledge could be obtained from the WSDL definition.etree.Elementorzeep.xsd.valueobjects.CompundValueSeems fair enough to always return
zeep.xsd.valueobjects.CompundValueso that the client will have to use its properties using the same WSDL definition as a source of truth about the response structure.