Closed ayushanand18 closed 1 year ago
I am confused about the syntax here. Why this:
return ChecklistResponse(url, {**args, **kwargs}, paginate=True)
instead of this:
return ChecklistResponse(url, paginate=True, *args, **kwargs)
I think you may have overtaken my python knowledge already. :sweat_smile: .
I have been looking more and understanding better... I am going to write this all out to be sure.
{**args, **kwargs}
splats two dicts into one dict. Part of my confusion was that args
here is a dict formed in the function, not the typical args
usage.
Consequences:
When there is a collision in this shorthand dict union the second one (kwargs
in this case) wins:
>>> {**{'a':1, 'b':2}, **{'a':2, 'c':3}}
{'a': 2, 'b': 2, 'c': 3}
I think this is a non-issue because kwargs will never contain a known arg.
When a bad kwarg is passed to the function it will propagate to the API. The API will either ignore the bad param or throw a 500 error. This is probably fine; we can add some more clever handling once someone reports being confused by it.
Other thoughts: what is the benefit of keeping any of the args? It is helpful to have the documentation, but perhaps we should just be pointing to api.obis.org for that information?
Thank you so much for the great observation. I want to summarize my chain of thought behind this implementation.
args
are different from the default args
which we generally have in methods. args
is a local dictionary being created based on the input arguments. I second with your conclusion in (1) that it won't be an issue in any situation because args
will automatically pick the arguments who's parameter has been defined in the parameter list. args
and kwargs
will be different in each case.OBIS API
completely ignores non-existent arguments (or bad kwargs) while executing the query.pysense
or a similar tool or maybe supported by their local IDE (even Google Colab supports it). So, it maybe a Saviour and not lead users to go back-and-forth with the package docs or API docs. I'm open to your thoughts on this.
Thank you for the added information; everything sounds great.
Thanks for your awesome continued support!
Thanks a ton! I'll continue to do so as long as I can find time :)
Overview
**kwargs
in resource fetching, andChanges Introduced
kwargs
acceptance.args
->{**args, **kwargs}
occurrence.get()
test to fetch the first record'sid
inoccurrences.get(id=occurrences.search(size=1).execute()['id'].values[0])
.Thanks!