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
Using a generic descriptor class for handling all Result class (all classes in mollie.api.objects.*) properties would allow us to remove lots of duplicate and repetitive code.
Code for all properties in all classes could be simplified like this:
classPayment: # mollie.api.objects.payment.Payment# Current code@propertydefcreated_at(self):
returnself._get_property("createdAt")
@propertydefauthorized_at(self):
returnself._get_property("authorizedAt")
# Possible replacement codecreated_at=ResultProperty()
authorized_at=ResultProperty()
The current property methods (def created_at() from above example) are written for almost every root property in each API response, so we have hundreds of them. They have been prone to subtle copy/paste and typo errors ever since they existed, and year-old errors are still discovered now and then. This proposal would remove them and replace them with a generic replacement.
Apart from all the duplicated code, we could gain:
A single place to manipulate/validate values returned from the API, in stead of many (hundreds) separate methods.
Writable properties. Currently there is no use for updating properties since there is no way to store or validate the updated values, but we could implement creating/updating from the Result object self:
Using a generic descriptor class for handling all Result class (all classes in
mollie.api.objects.*
) properties would allow us to remove lots of duplicate and repetitive code.Code for all properties in all classes could be simplified like this:
The current property methods (
def created_at()
from above example) are written for almost every root property in each API response, so we have hundreds of them. They have been prone to subtle copy/paste and typo errors ever since they existed, and year-old errors are still discovered now and then. This proposal would remove them and replace them with a generic replacement.Apart from all the duplicated code, we could gain:
Python docs on descriptor protocol (the pattern that would be used to implement the
ResultProperty
class): https://docs.python.org/3/howto/descriptor.htmlThe text was updated successfully, but these errors were encountered: