mollie / mollie-api-python

Mollie API client for Python
http://www.mollie.com
BSD 2-Clause "Simplified" License
113 stars 55 forks source link

Client `list()` method with `from` parameter raises SyntaxError #324

Closed whyscream closed 8 months ago

whyscream commented 1 year ago

The client provides list() methods for listing all kinds of resources. Most of the listing endpoints support pagination by providing a querystring like ?from=tr_12345&limit=42. We allow passing querystring parameters using generic keywords arguments to the list() method (and all other API interfacing methods), f.i.; client.payments.list(from="tr_12345", limit=42).

The problem is that from is a reserved word in Python, which means that you cannot actually use it as a keyword argument name: you'll get a SyntaxError exception:

  File "test.py", line 4
    client.payments.list(from="tr_12345")
                         ^
SyntaxError: invalid syntax

We need to find a proper solution for this.

whyscream commented 8 months ago

Adding more code is easy, but the best way to support this is just using a dictionary when passing parameters:

params = {"from": "tr_12345"}
payments = client.payments.list(**params)