swansonk14 / typed-argument-parser

Typed argument parser for Python
MIT License
494 stars 40 forks source link

Type safe way to access subparser arguments? #113

Closed aucampia closed 9 months ago

aucampia commented 1 year ago

As far as I can tell from your tests you access subparser arguments on the main parser class instead of the subparsers class, is this really how you expect people to do it?

https://github.com/swansonk14/typed-argument-parser/blob/eb55a9bf91b4675a0d8588b2a8f4947e48426336/tests/test_subparser.py#L180-L184

Is there a reason this is not documented?

Would it not be better to just say that this library does not support subparsers, because the current support really seems more of a nusiance than anything else. I think if I knew up front that the support for subcommands is in the state that it is I would not have tried using it and it would have saved me a lot of time.

oscarkey commented 1 year ago

See https://github.com/swansonk14/typed-argument-parser/issues/69

swansonk14 commented 1 year ago

Hi @aucampia,

Thank you for bringing up this issue! Tap implements subparsers this way because we match how Python's built-in argparse library handles subparsers: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_subparsers

We agree that this is not ideal and have thought about alternatives. Please feel free to give us suggestions in this document or in this issue.

Best, Jesse and Kyle