[issue45690] Argparse exclusive group inside required exclusive group displays incorrectly

2021-12-16 Thread Irit Katriel


Irit Katriel  added the comment:

Nesting argument groups and mutually exclusive groups is now deprecated (see 
issue22047). Thank you for the bug report.

--
nosy: +iritkatriel
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Deprecate unsupported nesting of argparse groups

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45690] Argparse exclusive group inside required exclusive group displays incorrectly

2021-11-02 Thread paul j3


paul j3  added the comment:

https://bugs.python.org/issue29553
Argparser does not display closing parentheses in nested mutex groups

supposedly fixed the parentheses for nested groups.  You can read its 
discussion and patches to see why it does not handle your case.

I don't see any examples have required groups.  [] is used for un-required, () 
for required.  This patch did not change how the usage was generated.  It just 
refined how excess [()] were removed.

Proper handling of groups requires a major rewrite of the usage formatter.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45690] Argparse exclusive group inside required exclusive group displays incorrectly

2021-11-02 Thread paul j3


paul j3  added the comment:

There was a bug/issue that addressed problems with nested 
mutually_exclusive_groups.  It should be easy to find.

The problem is that the usage formatter is brittle, building a string and then 
striping out "unnecessary" characters.  I assume the fix handled the default 
case (not required), but apparently it missed this variation.

I wasn't too involved with that, since in my opinion nesting these groups is 
useless, and should be avoided.  You might as well use one union group.  Test 
the parsing for yourself.

--
nosy: +paul.j3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45690] Argparse exclusive group inside required exclusive group displays incorrectly

2021-11-02 Thread andrew cooke


New submission from andrew cooke :

The code below, when invoked with -h, prints:

(.env) [andrew@localhost py]$ python -m tests_sa.argparse_bug -h
usage: argparse_bug.py [-h] (-a A | [-b B | -c C)]

options:
  -h, --help  show this help message and exit
  -a A
  -b B
  -c C

where the final two characters in the usage line are swapped.  It should be

usage: argparse_bug.py [-h] (-a A | [-b B | -c C])

or maybe even

usage: argparse_bug.py [-h] (-a A | (-b B | -c C))



from argparse import ArgumentParser

def main():
parser = ArgumentParser()
outer = parser.add_mutually_exclusive_group(required=True)
outer.add_argument('-a')
inner = outer.add_mutually_exclusive_group()
inner.add_argument('-b')
inner.add_argument('-c')
parser.parse_args()


if __name__ == '__main__':
main()

--
components: Library (Lib)
messages: 405509
nosy: acooke
priority: normal
severity: normal
status: open
title: Argparse exclusive group inside required exclusive group displays 
incorrectly
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com