-
Notifications
You must be signed in to change notification settings - Fork 18
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 typing #180
Comments
Great! Could you maybe add mypy as a test that is allowed to fail? So that while developing we can check how close we are to passing the test. Could mypy also check whether our function calls from our example notebooks, calls to external functions and function calls from the tests fully obey the typechecking? |
With mypy you can set it to either check for untyped definitions, but by default it does not. It would only check for correctness and not if everything is typed. We can work towards adding typing that way. Python type checkers also check calls to external functions (if those are typed, but most are nowadays, or have stubs available). As for tests and the notebooks, I don't think type checking there is necessary. For tests is would create more of a burden: the tests are there to check the functionality. |
Type hints are now quite well supported in Python. Unlike strongly typed languages (e.g. C or Java) these are not enforced on runtime. However, they are very useful both as a developer (to avoid bugs and have code work immediately the first time you run it), and for users (as this allows their IDE to know what type of objects will be returned).
Typing can be added progressively (adding types as we go) or I could go over the codebase and add types everywhere. We have only ~50 functions in total, so that should be quite doable.
Type correctness of the code can be enforced with tools like mypy.
The text was updated successfully, but these errors were encountered: