Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type safe way to access subparser arguments? #113

Closed
aucampia opened this issue Jun 13, 2023 · 2 comments
Closed

Type safe way to access subparser arguments? #113

aucampia opened this issue Jun 13, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@aucampia
Copy link

aucampia commented Jun 13, 2023

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?

args = Args().parse_args('b --blaz'.split())
self.assertFalse(args.foo)
self.assertFalse(hasattr(args, 'baz'))
self.assertFalse(hasattr(args, 'biz'))
self.assertTrue(args.blaz)

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
Copy link

See #69

@swansonk14
Copy link
Owner

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

@swansonk14 swansonk14 added duplicate This issue or pull request already exists enhancement New feature or request labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants