-
Notifications
You must be signed in to change notification settings - Fork 31
Coding Conventions
Written code must be compliant to the PEP 0008 -- Style Guide for Python Code.
Private class attributes or functions should be preceeded by "__". Protected class attributes or functions should be precced by "_".
Additionally, type-checking should be performed where appropriate (Issue #17). To this aim, function parameters should be annotated according to PEP 0484 -- Type Hints. A @typecheck decorator will be implemented to facilitate (optional) run-time type checks and static type-checking tools such as mypy will be employed.
Small example:
class Foo(Bar):
@typecheck()
def __init__(self):
self.x = 0 # public
self._foo = 7 # protected
self.__bar = 1 # private
self.some_long_name = "Obdulia Goodrum"
@typecheck()
def calculate_stuff(self, arg1: int, another_arg: List["Foo"] = None) -> List[float]:
# some implementation
Every package, module, class, method, attribute intended for public use should be documented according to PEP 0257 -- Docstring Conventions. Tools like doxygen or docutils will be used to extract the documentation from the code.
(Methods of) All classes should be thoroughly tested using Python's unit testing framework. Tests should aim to achieve path coverage to a reasonable degree. Correct/graceful handling of wrongly typed arguments should also be tested.