-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Labels
Description
Description
Accessing a non-existent property on an API returns None instead of raising an AttributeError
Steps to reproduce
Attempt to access any non-existent attribute on any subclass of AdyenBase
>>> from Adyen import Adyen
>>> api = Adyen(xapikey='token', platform='test')
>>> print(api.foobar)
None
>>> print(api.payment.payments_api.foobar)
None
>>> api.payment.payments_api.fizz()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
Actual behavior
Attempting to access non-existent attribute returns None. Attempting to call a non-existent method throws a "NoneType object is not callable" error.
Expected behavior
Should return an AttributeError.
Code snippet or screenshots (if applicable)
Root cause is here:
adyen-python-api-library/Adyen/services/base.py
Lines 13 to 16 in fa8079f
| def __getattr__(self, attr): | |
| client_attr = ["username", "password", "platform"] | |
| if attr in client_attr: | |
| return self.client[attr] |
If key doesn't exist in self.client, the method exits with no return statement, which is the same as returning None. This means any attribute that's requested defaults to None. It should instead raise AttributeError
Adyen Python API Library version
14.0.0
Python Language version
Python 3.10
Operating System
macOS
Additional context
No response