swansonk14/typed-argument-parser

[suggestion] Use `Annotated` instead of source code parsing.

LiraNuna opened this issue · 3 comments

typing.Annotated was introduced in Python 3.9. It seems like the perfect way to add help strings and other meta information.

class ExampleArguments(Tap):
    workers: Annotated[int, HelpString('The number of workers to run')]

Of course that will only work for python 3.9 and above.

I'd like to instead suggest a pattern similar to dataclass's field construct instead. Created #98 as an alternative

Hi @LiraNuna,

Thank you for the suggestion! We like your idea, but we are afraid that your solution would not work cleanly for long help strings since the default value would appear after the long help string. We prefer the alternative solution mentioned in #98. Thanks again for your suggestion and we would appreciate any thoughts on the alternate solution.

Best,
Jesse and Kyle

Thanks for your consideration and for taking a look. Should I close this in favor of #98?