-
Notifications
You must be signed in to change notification settings - Fork 2
Design Principles
Amatino Python aims to be as easy to integrate as possible. It should clearly signal its expectations. To that end, all Amatino code should enforce strict dynamic type checking. For example, if a function expects a str argument, and it is not provided with a str, it should immediately raise a TypeError.
The alternative is to fail in some derived manner. For example, an incorrect input type might manifest itself as a 400 - Bad Request response from the Amatino API. The reason for the failure is now obfuscated behind several layers of the call stack.
By enforcing strict dynamic type checking, Amatino Python makes the reasons for failure absolutely clear. TypeError descriptions should be concise, explicit, and comprehensive. For example:
def expects_string(foo: str):
if not is instance(foo, str):
raise TypeError('foo must be of type `str`')
# ...
expects_string(1) # Immediate and clear feedbackSome developers choose to enforce static type checking on their Python software. Amatino Python should meet the same standard of typing that such developers expect of their own code. Anything less would introduce a reason to avoid Amatino Python.
Static type checking is provided by strict PEP 484 compliance. During development, Amatino Python code should be linted by mypy or similarly PEP 484 compliant linting library.
Of course, static checking is optional. A developer who is unfamiliar with static type-checking, or wishes not to employ it, should be in no way inconvenienced or hindered by its inclusion.
- No more than 80 characters per line