mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 586 forks source link

Zeep 4.0.0 fails mypy checks when using bindings directly #1195

Open fennb opened 3 years ago

fennb commented 3 years ago
  1. Version 4.0.0
  2. WSDL: Any
  3. Example script/reproduction:
    
    from zeep import Client
    from zeep.wsdl.definitions import Binding

client = Client('http://www.soapclient.com/xml/soapresponder.wsdl') binding: Binding = client.wsdl.bindings['{http://www.SoapClient.com/xml/SoapResponder.wsdl}SoapResponderBinding'] operation = binding.get('Method1')

mypy example.py example.py:5: error: Too few arguments for "get" [call-arg] operation = binding.get('Method1')


The underlying cause of this seems to be the type annotation here: https://github.com/mvantellingen/python-zeep/blob/master/src/zeep/wsdl/wsdl.py#L184

I believe this should read:
```python
self.bindings = {}  # type: typing.Dict[str, Binding]

Otherwise, mypy thinks the value side of of the bindings dictionary is Type[Binding] rather than Binding itself, which means it could contain actual Binding classes, not instances of the Binding class.