Add support for using the Annotated
type to provide comments for the help string
#127
Labels
enhancement
New feature or request
Tap currently gets the help strings from the comments:
However, https://docs.python.org/3/library/typing.html#typing.Annotated allows users to provide both a type and a comment. Using
Annotated
, the above code becomes:One edge case is whether or not we should ignore surrounding comments when an argument is annotated. We're thinking that whenever there's an annotation for an argument, we should ignore the surrounding comments. For example,
A potential issue with this design is that
Annotated
can be used to specify refinement types (e.g., that an argument is positivearg: Annotated[int, Gt(0)]
). A solution would be to have a customTap
class forHelpString
and then only use annotations when the annotation is of typeHelpString
. For example,would provide the help string, but
and
would not contribute to the command line help string.
Another thought is that we could potentially support verification as in
pydantic
.--JK
The text was updated successfully, but these errors were encountered: