Skip to content

Rely more on mypy for the arguments type detection when sphinx generates the documentation #1292

@VincentRouvreau

Description

@VincentRouvreau

We started to use mypy for python, but IMHO, I think we should also rely on it for the documentation generation.

For example, in the dealunay_complex.py, we say:

    def __init__(
        self,
        points: Sequence[Sequence[float]] = [],
        weights: Optional[Sequence[float]] = None,
        precision: Literal["fast", "safe", "exact"] = "safe",
    ):
        """Args:
              points (Sequence[Sequence[float]]): A list of points in d-Dimension.
              weights (Optional[Sequence[float]]): A list of weights. If set, the number of weights must correspond to
                  the number of points.
              precision (str): Complex precision can be `'fast'`, `'safe'` or `'exact'`. Default is `'safe'`.

        :raises ValueError: In case of inconsistency between the number of points and weights.
        """

which gives the following documentation:

Image

But, if we rely on mypy for the arguments type detection when sphinx generates the documentation (here I remove the arguments types in between parenthesis):

    def __init__(
        self,
        points: Sequence[Sequence[float]] = [],
        weights: Optional[Sequence[float]] = None,
        precision: Literal["fast", "safe", "exact"] = "safe",
    ):
        """Args:
              points: A list of points in d-Dimension.
              weights: A list of weights. If set, the number of weights must correspond to
                  the number of points.
              precision: Complex precision can be `'fast'`, `'safe'` or `'exact'`. Default is `'safe'`.

        :raises ValueError: In case of inconsistency between the number of points and weights.
        """

The documentation looks like:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    docA documentation issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions