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

Crash when using action='store_true' #5

Open
Radagaisus opened this issue Jun 6, 2020 · 4 comments
Open

Crash when using action='store_true' #5

Radagaisus opened this issue Jun 6, 2020 · 4 comments

Comments

@Radagaisus
Copy link

Using parser.add_argument('--spectate', default=False, action='store_true') crashes with the following error:

Traceback (most recent call last):
...
  File "/opt/anaconda3/lib/python3.7/site-packages/argparse_prompt.py", line 30, in add_argument
    action = super().add_argument(*args, type=type, default='', **kwargs)
  File "/opt/anaconda3/lib/python3.7/argparse.py", line 1353, in add_argument
    action = action_class(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'type'

Problem is here. Passing a type when it’s not needed will cause Argparse to throw the error.

@multimeric
Copy link
Owner

This is a bit tricky, since the library requires the type mechanism in order to hook into argparse. I guess I'll have to patch my own version of it somehow.

@Radagaisus
Copy link
Author

@TMiguelT Wouldn’t it be easier to just skip flags with this action? False is used by default if they’re not added, True if the flag is present — no real need for a prompt.

@multimeric
Copy link
Owner

That's missing the point of this lib, though. That's just default argparse behaviour. If you want that, you can just use prompt=False, but eventually I'm going to have to work out how to deal with this properly.

@voldemortX
Copy link

Hi guys! What is the status of this problem now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants