QuantEcon / QuantEcon/QuantEcon.py

Use Mypy annotation for arguments and return type documentation

Open
#565 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discuss
Dominant language
Python
Stars
2.4k
Forks
2.3k
Avg merge
3d 3h
Merged PRs (30d)
3

Description

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:

class RepeatedGame:
    def __init__(self, stage_game: NormalFormGame, delta: float):
        ...
    def equilibrium_payoffs(
        self,
        method: Optional[str]=None,
        options: Optional[Dict[str, Any]]=None) -> None:
        ...

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the RepeatedGame documentation example in game_theory.repeated_game and compare its argument and return-type presentation with the sphinx-autodoc-typehints guidance. Review the referenced Mesa annotations as a model; done means the relevant Python signatures use Mypy annotations and Sphinx displays those types consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.