MechMicroMan / DefDAP

A python library for correlating EBSD and HRDIC data
Apache License 2.0
36 stars 18 forks source link

Add type hinting #80

Open rhysgt opened 3 years ago

rhysgt commented 3 years ago

Details here: https://docs.python.org/3/library/typing.html. Already finished the process on the following functions:

I have also added a sphinx extension, which means that we no longer need the type in the arguments in docstring.

Note: If you want to specify a description of what is returned, then you also need the return type in the docstring (even if it's type hinted). Note: Numpy are adding a typing library in 1.20.0, until then it is not possible to use 'np.array[Quat]' (for example) as a type, so I have not fully defined the type in this case and have left it in the docstring instead. In future, will be able do from np.typing import ArrayLike then ArrayLike[Quat] as a type hint. Note: When referring to the parent class from a method type hint, a string literal needs to be used for forward reference in python <3.10. Postponed evaluation of annotations has been added in Python 3.10 (see https://www.python.org/dev/peps/pep-0563/).

Started in #79