dadadel / pyment

Format and convert Python docstrings and generates patches
GNU General Public License v3.0
898 stars 63 forks source link

Feature Request: docstring style for sphinx-autodoc-typehints #124

Open jgarte opened 2 years ago

jgarte commented 2 years ago

https://pypi.org/project/sphinx-autodoc-typehints/

Instead of

def format_unit(value, unit):
    """
    Formats the given value as a human readable string using the given units.

    :param float|int value: a numeric value
    :param str unit: the unit for the value (kg, m, etc.)
    :rtype: str
    """
    return f"{value} {unit}"

We produce this

from typing import Union

def format_unit(value: Union[float, int], unit: str) -> str:
    """
    Formats the given value as a human readable string using the given units.

    :param value: a numeric value
    :param unit: the unit for the value (kg, m, etc.)
    """
    return f"{value} {unit}"

wdyt

gartangh commented 1 year ago

I would also like a flag that disables types for parameters / return types (especially for Google style docstrings), so that sphinx-autodoc-typehints can do its thing.