-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I would like to propose introducing type annotations to BioPython.
For those unfamiliar, type annotations are specified by PEP 484 and add static type-checking to python code. Two syntaxes are available; an annotation syntax for python 3 and a type comment syntax which is compatible with python 2 code. For example:
def f(num1, my_float=3.5):
# type: (int, float) -> float
return num1 + my_floatThe annotations are no-ops at runtime, but allow type checking tools to be run over the code (e.g. as a tox test) to detect type errors. The python community has standardized on the MyPy type checking package for the static analysis.
Code without a type annotation is treated permissively by the type checker, so types can be added incrementally to the project over time.
BioPython could start providing types for some core data structures using the py27 comment syntax. At whatever point BioPython drops 2.7 support (after 2020), development could then switch to using the cleaner annotation syntax.