Skip to content

Use Mypy annotation for arguments and return type documentation #565

Open
@rht

Description

@rht

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions