[issue46057] argparse: embedded groups may prevent options from being in help output

2022-01-02 Thread László Attila Tóth
László Attila Tóth added the comment: I don't think I'm adventurous as I try to use its public API. If something is public in the pythonic terms (no underscore before it), but undocumented, that can obviously mean two things: either the documentation is outdated or the API

[issue22047] Deprecate unsupported nesting of argparse groups

2021-12-17 Thread László Attila Tóth
László Attila Tóth added the comment: Hi, according to the group update the _MutuallyExclusiveGroup should have an add_argument_group() call with the deprecation warning, but that method is missing in commit 30322c497e0b8d978f7a0de95985aac9c5daf1ac. -- nosy: +Laszlo.Attila.Toth

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-13 Thread László Attila Tóth
László Attila Tóth added the comment: my idea regarding _ArgumentGroup,add_argument_group is in the attached file. This doesn't solve the complete help output issue, but addresses the incorrectly called _ArgumentGroup.add_argument_group - a warn() call and return self. As a result the

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-12 Thread László Attila Tóth
László Attila Tóth added the comment: According to the documentation only the ArgumentParser has add_argument_group option, which is not true, the code allows me to add a subgroup to any group. The complete example is in issue 4608: https://bugs.python.org/issue46058 If add_argument_group

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-12 Thread László Attila Tóth
László Attila Tóth added the comment: The fix is something like this for _ArgumentGroup, but as the container may not be an _ArgumentGroup, it breaks the tests. --- Lib/argparse.py +++ Lib/argparse.py @@ -1635,9 +1640,13 @@ def __init__(self, container, title=None, description=None, **kwargs

[issue46058] argparse: arg groups and mutually exclusive groups behave inconsitently

2021-12-12 Thread László Attila Tóth
László Attila Tóth added the comment: Checking the code the add_mutually_exclusive_group has only kwargs, so one part can be fixed (POC, breaks tests): --- Lib/argparse.py +++ Lib/argparse.py @@ -1648,8 +1648,8 @@ def _remove_action(self, action): class _MutuallyExclusiveGroup

[issue46058] argparse: arg groups and mutually exclusive groups behave inconsitently

2021-12-12 Thread László Attila Tóth
New submission from László Attila Tóth : I tried to add arguments to process DB-related settings, either from typing import Optional from a file or explicitly specifying them. In theory with nested groups (by add_argument_group and add_mutually_exlusive_group) this can be implemented in almost

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-12 Thread László Attila Tóth
László Attila Tóth added the comment: And the leading part is the same for both the mutually exclusive and the argument groups: usage: test1.py [-h] [--db-config DB_CONFIG] [--db-password DB_PASSWORD] optional arguments: -h, --helpshow this help message and exit Database

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-12 Thread László Attila Tóth
László Attila Tóth added the comment: Sorry, these are two bugs in fact. The current one, the help with minmal code: import argparse parser = argparse.ArgumentParser() grp = parser.add_argument_group('Database settings') grp.add_argument('--db-config') xgrp = gr

[issue46057] argparse: embedded groups may prevent options from being in help output

2021-12-12 Thread László Attila Tóth
New submission from László Attila Tóth : I tried to use the following code where the --db-password is not shown in the --help output (Originally I wanted to use mutually exclusive groups but that feature also works strangely, so I changed them to regular groups). def register_db_args(parser

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2015-02-28 Thread László Attila Tóth
László Attila Tóth added the comment: It seems I found the solution in the attached file argparse.disable_interspersed_args.python35.diff, and it's much-much easier than I thought. I assume that this patch can cleanly applied to earlier versions (python 3.2-3.4), but I didn'

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2013-02-02 Thread László Attila Tóth
László Attila Tóth added the comment: Unfortunatelly the implementation bugous as of now. I wrote additional tests. self.parser = ErrorRaisingArgumentParser() self.parser.add_argument('-a', action='store_true') self.parser.add_argument('-b') self.pa

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2012-02-17 Thread László Attila Tóth
László Attila Tóth added the comment: I added unit test, which revealed some bugs. These are fixe now. The attached file contains both the unit tests and the updated patch. -- Added file: http://bugs.python.org/file24546/argparse-disable_interspersed.patch

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2012-02-07 Thread László Attila Tóth
New submission from László Attila Tóth : If someone ports his code from optparse to argparse, there is a limit, that options and non-options can be mixed by default, and this behaviour cannot be disabled easily, an extra '--' argument is required in the command line. In some cases