From 31fe51894cc3f5d35e84127f07e44f23c16d85d4 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sat, 12 Oct 2024 16:01:49 -0700 Subject: [PATCH 1/6] Add argument_default and conflict_handler to add_argument_group docs --- Doc/library/argparse.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index d58c75eef3e739..33ad6706f271ee 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1808,7 +1808,9 @@ FileType objects Argument groups ^^^^^^^^^^^^^^^ -.. method:: ArgumentParser.add_argument_group(title=None, description=None) +.. method:: ArgumentParser.add_argument_group(title=None, description=None, \ + argument_default=None, \ + conflict_handler='error') By default, :class:`ArgumentParser` groups command-line arguments into "positional arguments" and "options" when displaying help From c25fca418f779cf89e69b5de1a34355ea2a70800 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sun, 13 Oct 2024 13:54:02 -0700 Subject: [PATCH 2/6] Address PR comments --- Doc/library/argparse.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 33ad6706f271ee..f12f19ab733efb 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1809,8 +1809,7 @@ Argument groups ^^^^^^^^^^^^^^^ .. method:: ArgumentParser.add_argument_group(title=None, description=None, \ - argument_default=None, \ - conflict_handler='error') + [argument_default], [conflict_handler]) By default, :class:`ArgumentParser` groups command-line arguments into "positional arguments" and "options" when displaying help @@ -1855,6 +1854,13 @@ Argument groups --bar BAR bar help + The optional parameters *argument_default* and *conflict_handler* allow + for finer-grained control of the behavior of the argument group. Both + of these parameters behave similarly to *argument_default* and + *conflict_handler* parameters of :meth:`~ArgumentParser.add_argument`. + However, when passes into :meth:`add_argument_group`, these parameters apply + to all arguments added to the group. + Note that any arguments not in your user-defined groups will end up back in the usual "positional arguments" and "optional arguments" sections. From 65654bb4458fa7264253108750313dbb11e2ccec Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sun, 13 Oct 2024 14:04:17 -0700 Subject: [PATCH 3/6] Add * --- Doc/library/argparse.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index f12f19ab733efb..d450b887d51da0 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1808,8 +1808,9 @@ FileType objects Argument groups ^^^^^^^^^^^^^^^ -.. method:: ArgumentParser.add_argument_group(title=None, description=None, \ - [argument_default], [conflict_handler]) +.. method:: ArgumentParser.add_argument_group(title, description, \ + [*argument_default], \ + [*conflict_handler]) By default, :class:`ArgumentParser` groups command-line arguments into "positional arguments" and "options" when displaying help From 742b116f29c372a0e6c13c0f753eeb022db8207c Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 14 Oct 2024 21:43:27 -0700 Subject: [PATCH 4/6] Make description more concise --- Doc/library/argparse.rst | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index d450b887d51da0..0f85d211f1d7ab 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1808,9 +1808,8 @@ FileType objects Argument groups ^^^^^^^^^^^^^^^ -.. method:: ArgumentParser.add_argument_group(title, description, \ - [*argument_default], \ - [*conflict_handler]) +.. method:: ArgumentParser.add_argument_group(title=None, description=None, *, \ + [argument_default], [conflict_handler]) By default, :class:`ArgumentParser` groups command-line arguments into "positional arguments" and "options" when displaying help @@ -1855,12 +1854,11 @@ Argument groups --bar BAR bar help - The optional parameters *argument_default* and *conflict_handler* allow - for finer-grained control of the behavior of the argument group. Both - of these parameters behave similarly to *argument_default* and - *conflict_handler* parameters of :meth:`~ArgumentParser.add_argument`. - However, when passes into :meth:`add_argument_group`, these parameters apply - to all arguments added to the group. + The optional keyword-only parameters argument_default_ and conflict_handler_ allow + for finer-grained control of the behavior of the argument group. These + parameters have the same meaning as in the :class:`~ArgumentParser` constructor, + but apply specifically to the argument group rather than the entire parser. + Note that any arguments not in your user-defined groups will end up back in the usual "positional arguments" and "optional arguments" sections. From 03b1ad217e11d2ef5fa8916edc868ec4db32cf72 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Mon, 14 Oct 2024 21:44:30 -0700 Subject: [PATCH 5/6] Remove newline --- Doc/library/argparse.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 0f85d211f1d7ab..07c93c2a5d6a4e 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1854,12 +1854,11 @@ Argument groups --bar BAR bar help - The optional keyword-only parameters argument_default_ and conflict_handler_ allow - for finer-grained control of the behavior of the argument group. These + The optional, keyword-only parameters argument_default_ and conflict_handler_ + allow for finer-grained control of the behavior of the argument group. These parameters have the same meaning as in the :class:`~ArgumentParser` constructor, but apply specifically to the argument group rather than the entire parser. - Note that any arguments not in your user-defined groups will end up back in the usual "positional arguments" and "optional arguments" sections. From 2cbf230547e775fdb2866adfa92f72afbd6775c6 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Tue, 15 Oct 2024 08:24:28 -0700 Subject: [PATCH 6/6] Lint --- Doc/library/argparse.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 07c93c2a5d6a4e..51ab8e29ff96d5 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1854,9 +1854,9 @@ Argument groups --bar BAR bar help - The optional, keyword-only parameters argument_default_ and conflict_handler_ - allow for finer-grained control of the behavior of the argument group. These - parameters have the same meaning as in the :class:`~ArgumentParser` constructor, + The optional, keyword-only parameters argument_default_ and conflict_handler_ + allow for finer-grained control of the behavior of the argument group. These + parameters have the same meaning as in the :class:`ArgumentParser` constructor, but apply specifically to the argument group rather than the entire parser. Note that any arguments not in your user-defined groups will end up back