Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hinting #80

Open
5 of 9 tasks
rhysgt opened this issue Mar 2, 2021 · 0 comments
Open
5 of 9 tasks

Add type hinting #80

rhysgt opened this issue Mar 2, 2021 · 0 comments

Comments

@rhysgt
Copy link
Contributor

rhysgt commented Mar 2, 2021

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

  • base.py
  • crystal.py
  • file_readers.py
  • file_writers.py
  • hrdic.py
  • inspector.py
  • plotting.py
  • quat.py
  • utils.py

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant