From 5add876b4cdd2921a79adc49e65eb6a3109bd1e7 Mon Sep 17 00:00:00 2001 From: Santi Hernandez Date: Mon, 13 Apr 2026 16:43:28 -0600 Subject: [PATCH 1/4] gh-72406: Document argument ordering in argparse help output --- Doc/library/argparse.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 0091bf95f0cef0..0da227d5dbb703 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -699,6 +699,8 @@ The add_argument() method * deprecated_ - Whether or not use of the argument is deprecated. The method returns an :class:`Action` object representing the argument. + Within each argument group, arguments are displayed in help output in the + order in which they are added. The following sections describe how each of these are used. From 016b619c4e69777e91759446fac58e01c20e6c82 Mon Sep 17 00:00:00 2001 From: Santi Hernandez Date: Mon, 13 Apr 2026 16:46:55 -0600 Subject: [PATCH 2/4] Add NEWS entry --- .../Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst diff --git a/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst b/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst new file mode 100644 index 00000000000000..509584dfa6f47d --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst @@ -0,0 +1 @@ +Document that arguments are displayed in help output in the order they were added within each argument group. \ No newline at end of file From c66f20b5098506e3f58ab26266209e3614ae538a Mon Sep 17 00:00:00 2001 From: Santi Hernandez Date: Mon, 13 Apr 2026 17:01:12 -0600 Subject: [PATCH 3/4] Fix missing newline in NEWS entry --- .../Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst b/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst index 509584dfa6f47d..9ec717bb3af077 100644 --- a/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst +++ b/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst @@ -1 +1 @@ -Document that arguments are displayed in help output in the order they were added within each argument group. \ No newline at end of file +Document that arguments are displayed in help output in the order they were added within each argument group. From 4f72246030bd5d49d191d933f3ddbb57ed52b320 Mon Sep 17 00:00:00 2001 From: Santi Hernandez Date: Mon, 13 Apr 2026 20:23:18 -0600 Subject: [PATCH 4/4] Move note to Argument groups section, remove NEWS entry --- Doc/library/argparse.rst | 5 +++-- .../2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 0da227d5dbb703..e37afd6d0b6d5a 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -699,8 +699,6 @@ The add_argument() method * deprecated_ - Whether or not use of the argument is deprecated. The method returns an :class:`Action` object representing the argument. - Within each argument group, arguments are displayed in help output in the - order in which they are added. The following sections describe how each of these are used. @@ -2034,6 +2032,9 @@ Argument groups Note that any arguments not in your user-defined groups will end up back in the usual "positional arguments" and "optional arguments" sections. + Within each argument group, arguments are displayed in help output in the + order in which they are added. + .. deprecated-removed:: 3.11 3.14 Calling :meth:`add_argument_group` on an argument group now raises an exception. This nesting was never supported, often failed to work diff --git a/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst b/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst deleted file mode 100644 index 9ec717bb3af077..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2026-04-13-15-50-00.gh-issue-72406.Xk9mPq.rst +++ /dev/null @@ -1 +0,0 @@ -Document that arguments are displayed in help output in the order they were added within each argument group.