[issue32756] argparse: parse_known_args: raising exception on unknown arg following known one

2018-02-14 Thread Yauhen

Yauhen <actionless.lovel...@gmail.com> added the comment:

I am adding one more testcase in order to clarify more the problem:



import argparse
import sys

parser = argparse.ArgumentParser(prog=sys.argv[0], add_help=False)
parser.add_argument('-a', action='store_true')
parser.add_argument('-b', action='store_true')
parser.add_argument('-c', action='store_true')
parsed_args, unknown_args = parser.parse_known_args(sys.argv[1:])
print(parsed_args)
print(unknown_args)



$ python argparse_test.py -ab
Namespace(a=True, b=True, c=False)
[]


Expected result:
$ python argparse_test.py -ab -cd
Namespace(a=True, b=True, c=True)
['-d']

Actual result:
$ python argparse_test.py -ab -cd
usage: argparse_test.py [-a] [-b] [-c]
argparse_test.py: error: argument -c: ignored explicit argument 'd'

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32756>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32756] argparse: parse_known_args: raising exception on unknown arg following known one

2018-02-03 Thread Yauhen

Yauhen <actionless.lovel...@gmail.com> added the comment:

It was a mistake in expected result, should be:

$ python arparse_test.py -ab -c
Namespace(a=True)
['-b', '-c']

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32756>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32756] argparse: parse_known_args: raising exception on unknown arg following known one

2018-02-03 Thread Yauhen

New submission from Yauhen <actionless.lovel...@gmail.com>:

steps to reproduce:

import argparse
import sys

parser = argparse.ArgumentParser(prog=sys.argv[0], add_help=False)
parser.add_argument('-a', action='store_true')
parsed_args, unknown_args = parser.parse_known_args(sys.argv[1:])
print(parsed_args)
print(unknown_args)


Expected result:

$ python arparse_test.py -ab
Namespace(a=True)
['b']


Actual result:

$ python arparse_test.py -ab
usage: arparse_test.py [-a]
arparse_test.py: error: argument -a: ignored explicit argument 'b'

--
components: Library (Lib)
messages: 311546
nosy: actionless
priority: normal
pull_requests: 5345
severity: normal
status: open
title: argparse: parse_known_args: raising exception on unknown arg following 
known one
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32756>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com