Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

parsing only a subset and leave all other checks undone #103

Closed
ghost opened this issue Sep 12, 2019 · 3 comments
Closed

parsing only a subset and leave all other checks undone #103

ghost opened this issue Sep 12, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 12, 2019

i try to extract just one optional arg also other nonoptionals might not have been supplied:

import argparse
parser.add_argument('d', help='dunt')
parser.add_argument('-c', help='copper')
args = parser.parse_known_args(args=['-c'])
 
usage: main.py [-h] [-c C] d
main.py: error: argument -c: expected one argument

It should only extract -c and leave d alone. I try to put -c into an external file which should silently do its thing without other arg checking , in this case 'd'. Why even throw on optional here.

violating the doc?

that it does not produce an error when extra arguments are present.

now if i try


parser.add_argument('-c', help='copper')
args = parser.parse_known_args(args=['-c'])

it throws on an optional one, shouldnt since c=None then

@ThomasWaldmann
Copy link
Owner

https://github.com/ThomasWaldmann/argparse/blob/master/README.txt

did you read this? closing.

@ghost
Copy link
Author

ghost commented Sep 13, 2019

Yes i did now, so file a bug report for the lib maintainers? i use 3.7 stdlib version (if it is one)

@ThomasWaldmann
Copy link
Owner

i didn't analyze your bug report, this is the wrong place in any case.

either ask on the python support channels or directly file a bug, if you are confident it is one.

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

No branches or pull requests

1 participant