-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Use Mypy annotation for arguments and return type documentation #565
Comments
This is the classic blog post on Mypy (as the url says, 2016): https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy/
|
thanks @rht I like this idea. PR's are welcome. |
Also wanted to point out that with type annotations, it'd be more equivalent to the Julia version of this repo. |
I fully agree, for all the reasons mentioned by @rht . The only thing is that it would have to be quite consistent across the lectures, and that's a large task requiring some coordination. Unfortunately I don't have the bandwidth to implement this myself but further discussion leading to PRs is very welcome. |
I tried to annotate normal_form_game.py in #576. Current 3rd party alternative solutions: numpy/numpy#7370 (comment). |
With Mypy, the types can be checked explicitly. While I think in Sphinx, the types are just strings? (E.g. https://quanteconpy.readthedocs.io/en/latest/game_theory/repeated_game.html#quantecon.game_theory.repeated_game.RepeatedGame)
Sphinx can be configured to accept Mypy annotation: https://github.com/agronholm/sphinx-autodoc-typehints.
With Mypy, the type annotation would be:
More example of Mypy annotations: https://github.com/projectmesa/mesa/blob/d376920146ca0ec422286cb8434d86b74e64b2fa/mesa/space.py. In particular https://github.com/projectmesa/mesa/blob/d376920146ca0ec422286cb8434d86b74e64b2fa/mesa/space.py#L191-L197.
The text was updated successfully, but these errors were encountered: