Describe the bug
If an endpoint argument is given the same name as an argument to apiron.client.call, it will not be passed through to the formatter.
To Reproduce
>>> from apiron import JsonEndpoint, Service
>>> class GitHub(Service):
... domain = 'https://api.github.com'
... user = JsonEndpoint(path='/users/{method}')
...
>>> response = GitHub.user(method='defunkt')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/apiron/src/apiron/client.py", line 238, in call
request = _build_request_object(
File "/apiron/src/apiron/client.py", line 112, in _build_request_object
path = endpoint.get_formatted_path(**kwargs)
File "/apiron/src/apiron/endpoint/endpoint.py", line 127, in get_formatted_path
return self.path.format(**kwargs)
KeyError: 'method'
Expected behavior
The simplest improvement would be if endpoints raised an exception when such collisions occur. This way there would be a better error message at evaluation time rather than a less clear exception when the endpoint is called.
Really though, apiron should be restructured so that kwargs passed into an endpoint aren't intermingled with those passed to apiron.client.call.
Environment:
- OS: linux
- Python version 3.10.7
apiron version 7d1d059
Describe the bug
If an endpoint argument is given the same name as an argument to
apiron.client.call, it will not be passed through to the formatter.To Reproduce
Expected behavior
The simplest improvement would be if endpoints raised an exception when such collisions occur. This way there would be a better error message at evaluation time rather than a less clear exception when the endpoint is called.
Really though, apiron should be restructured so that kwargs passed into an endpoint aren't intermingled with those passed to
apiron.client.call.Environment:
apironversion 7d1d059