-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Sometimes it can make sense to have a custom, more readable description of the argument where the raw type would be:
A = int | str
Listable[T] = T | list[T]
def f(a: Listable[A]):
"""Do something.
Parameters
----------
a : int or str or list of such objects
The input.
"""In this case (and I would hope, many others), it would be cool to automate the human-readable type documentation, e.g.
# Introducing `TypeDescription`, to differentiate it from
# `Description` which is really more of a "parameter description"
MyUnion = Annotated[Union, TypeDescription(lambda types: " or ".join(map(str, types)))]
Input = Annotated[MyUnion[int, str, bool], Description("The input.")]
@docstring("numpydoc")
def f(a: Input):
"""Do something."""which would result in
Help on ParsedFunc in module docstrands.parsed_func:
<function f>
Do something.
Parameters
----------
a : int or str or bool
The input.
When I discovered DocStrands this is one of the features I looked for.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels