From e9bf8751976b0bbc538a498e6fb86e5ba87f9109 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 19:40:21 -0800 Subject: [PATCH 01/11] Remove functionality and update docs --- Doc/library/argparse.rst | 29 ++++++++++------- Doc/whatsnew/3.14.rst | 8 +++++ Lib/argparse.py | 20 ------------ Lib/test/test_argparse.py | 68 --------------------------------------- 4 files changed, 26 insertions(+), 99 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index a4695547921faa..b397791c87d0f4 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1908,13 +1908,16 @@ 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. - .. versionchanged:: 3.11 - Calling :meth:`add_argument_group` on an argument group is deprecated. - This feature was never supported and does not always work correctly. - The function exists on the API by accident through inheritance and - will be removed in the future. + .. deprecated:: 3.11 + Calling :meth:`add_argument_group` on an argument group is deprecated. + This feature was never supported and does not always work correctly. + The function exists on the API by accident through inheritance and + will be removed in the future. - .. deprecated:: 3.14 + .. versionchanged:: 3.14 + Calling :meth:`add_argument_group` on an argument group has been removed. + + .. deprecated-removed:: 3.14 Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated. @@ -1975,11 +1978,15 @@ Mutual exclusion --foo FOO foo help --bar BAR bar help - .. versionchanged:: 3.11 - Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` - on a mutually exclusive group is deprecated. These features were never - supported and do not always work correctly. The functions exist on the - API by accident through inheritance and will be removed in the future. + .. deprecated:: 3.11 + Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` + on a mutually exclusive group is deprecated. These features were never + supported and do not always work correctly. The functions exist on the + API by accident through inheritance and will be removed in the future. + + .. deprecated-removed:: 3.14 + Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` + on a mutually exclusive group has been removed. Parser defaults diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index bc4ab6789e1676..93639d7b183832 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -641,6 +641,14 @@ argparse of :class:`!argparse.BooleanOptionalAction`. They were deprecated since 3.12. +* Calling :meth:`add_argument_group` on an argument group, and calling + :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` on + a mutually exclusive group have been removed. This nesting was never + supported, did not always work correctly, and existed in the API by + accident through inheritance. This functionality has been deprecated + since Python 3.11. + (Contributed by Savannah Ostrowski in :gh:`xxxxxxx`.) + ast --- diff --git a/Lib/argparse.py b/Lib/argparse.py index 5ecfdca17175e3..852191fa5022cd 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1708,16 +1708,6 @@ def _remove_action(self, action): super(_ArgumentGroup, self)._remove_action(action) self._group_actions.remove(action) - def add_argument_group(self, *args, **kwargs): - import warnings - warnings.warn( - "Nesting argument groups is deprecated.", - category=DeprecationWarning, - stacklevel=2 - ) - return super().add_argument_group(*args, **kwargs) - - class _MutuallyExclusiveGroup(_ArgumentGroup): def __init__(self, container, required=False): @@ -1737,16 +1727,6 @@ def _remove_action(self, action): self._container._remove_action(action) self._group_actions.remove(action) - def add_mutually_exclusive_group(self, *args, **kwargs): - import warnings - warnings.warn( - "Nesting mutually exclusive groups is deprecated.", - category=DeprecationWarning, - stacklevel=2 - ) - return super().add_mutually_exclusive_group(*args, **kwargs) - - def _prog_name(prog=None): if prog is not None: return prog diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 358cfb1c56aae4..0ae84b55aa00b3 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3621,55 +3621,6 @@ def get_parser(self, required): -c c help ''' -class TestMutuallyExclusiveNested(MEMixin, TestCase): - - # Nesting mutually exclusive groups is an undocumented feature - # that came about by accident through inheritance and has been - # the source of many bugs. It is deprecated and this test should - # eventually be removed along with it. - - def get_parser(self, required): - parser = ErrorRaisingArgumentParser(prog='PROG') - group = parser.add_mutually_exclusive_group(required=required) - group.add_argument('-a') - group.add_argument('-b') - with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - group2 = group.add_mutually_exclusive_group(required=required) - group2.add_argument('-c') - group2.add_argument('-d') - with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - group3 = group2.add_mutually_exclusive_group(required=required) - group3.add_argument('-e') - group3.add_argument('-f') - return parser - - usage_when_not_required = '''\ - usage: PROG [-h] [-a A | -b B | [-c C | -d D | [-e E | -f F]]] - ''' - usage_when_required = '''\ - usage: PROG [-h] (-a A | -b B | (-c C | -d D | (-e E | -f F))) - ''' - - help = '''\ - - options: - -h, --help show this help message and exit - -a A - -b B - -c C - -d D - -e E - -f F - ''' - - # We are only interested in testing the behavior of format_usage(). - test_failures_when_not_required = None - test_failures_when_required = None - test_successes_when_not_required = None - test_successes_when_required = None - class TestMutuallyExclusiveOptionalOptional(MEMixin, TestCase): def get_parser(self, required=None): @@ -4840,25 +4791,6 @@ def test_all_suppressed_mutex_with_optional_nargs(self): usage = 'usage: PROG [-h]\n' self.assertEqual(parser.format_usage(), usage) - def test_nested_mutex_groups(self): - parser = argparse.ArgumentParser(prog='PROG') - g = parser.add_mutually_exclusive_group() - g.add_argument("--spam") - with warnings.catch_warnings(): - warnings.simplefilter('ignore', DeprecationWarning) - gg = g.add_mutually_exclusive_group() - gg.add_argument("--hax") - gg.add_argument("--hox", help=argparse.SUPPRESS) - gg.add_argument("--hex") - g.add_argument("--eggs") - parser.add_argument("--num") - - usage = textwrap.dedent('''\ - usage: PROG [-h] [--spam SPAM | [--hax HAX | --hex HEX] | --eggs EGGS] - [--num NUM] - ''') - self.assertEqual(parser.format_usage(), usage) - def test_long_mutex_groups_wrap(self): parser = argparse.ArgumentParser(prog='PROG') g = parser.add_mutually_exclusive_group() From 41464a52f0c357a0bd4fd41652807e2eadf15f40 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 20:46:50 -0800 Subject: [PATCH 02/11] Change error type --- Lib/argparse.py | 6 ++++++ Lib/test/test_argparse.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Lib/argparse.py b/Lib/argparse.py index 852191fa5022cd..7a84f5dc24cf46 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1708,6 +1708,9 @@ def _remove_action(self, action): super(_ArgumentGroup, self)._remove_action(action) self._group_actions.remove(action) + def add_argument_group(self, *args, **kwargs): + raise ValueError('nested argument groups are not supported') + class _MutuallyExclusiveGroup(_ArgumentGroup): def __init__(self, container, required=False): @@ -1727,6 +1730,9 @@ def _remove_action(self, action): self._container._remove_action(action) self._group_actions.remove(action) + def add_mutually_exclusive_group(self, **kwargs): + raise ValueError('nested mutually exclusive groups are not supported') + def _prog_name(prog=None): if prog is not None: return prog diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 0ae84b55aa00b3..eff3c278183d88 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -2954,6 +2954,13 @@ def test_group_prefix_chars_default(self): self.assertEqual(msg, str(cm.warning)) self.assertEqual(cm.filename, __file__) + def test_nested_argument_group(self): + parser = argparse.ArgumentParser() + g = parser.add_argument_group() + self.assertRaisesRegex(ValueError, + 'nested argument groups are not supported', + g.add_argument_group) + # =================== # Parent parser tests # =================== @@ -3254,6 +3261,14 @@ def test_empty_group(self): with self.assertRaises(ValueError): parser.parse_args(['-h']) + def test_nested_mutex_groups(self): + parser = argparse.ArgumentParser(prog='PROG') + g = parser.add_mutually_exclusive_group() + g.add_argument("--spam") + self.assertRaisesRegex(ValueError, + 'nested mutually exclusive groups are not supported', + g.add_mutually_exclusive_group) + class MEMixin(object): def test_failures_when_not_required(self): From b9f3e4dba737e025bf75a9251f9079eb02ce7072 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 23 Nov 2024 04:54:45 +0000 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst new file mode 100644 index 00000000000000..cd29c284884c47 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst @@ -0,0 +1 @@ +Calling :meth:`add_argument_group` on an argument group, and calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` on a mutually exclusive group have been removed. This nesting was never supported, did not always work correctly, and existed in the API by accident through inheritance. This functionality has been deprecated since Python 3.11. From 76aadc6ff12e088e89e1c00f835e9a9c2262e6ae Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 20:55:17 -0800 Subject: [PATCH 04/11] Add PR number --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 93639d7b183832..c0ec367cded88b 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -647,7 +647,7 @@ argparse supported, did not always work correctly, and existed in the API by accident through inheritance. This functionality has been deprecated since Python 3.11. - (Contributed by Savannah Ostrowski in :gh:`xxxxxxx`.) + (Contributed by Savannah Ostrowski in :gh:`127186`.) ast --- From 16732775b1a9a89fae66e8c49e0178559085d31a Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 22:05:58 -0800 Subject: [PATCH 05/11] Fix sphinx --- Doc/library/argparse.rst | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 440638e9065764..230dfe7148d140 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1926,16 +1926,12 @@ 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. - .. deprecated:: 3.11 - Calling :meth:`add_argument_group` on an argument group is deprecated. - This feature was never supported and does not always work correctly. - The function exists on the API by accident through inheritance and - will be removed in the future. - - .. versionchanged:: 3.14 + .. deprecated-removed:: 3.11 3.14 Calling :meth:`add_argument_group` on an argument group has been removed. + This feature was never supported and did not always work correctly. + The function existed on the API by accident through inheritance. - .. deprecated-removed:: 3.14 + .. deprecated:: 3.14 Passing prefix_chars_ to :meth:`add_argument_group` is now deprecated. @@ -1996,15 +1992,11 @@ Mutual exclusion --foo FOO foo help --bar BAR bar help - .. deprecated:: 3.11 - Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` - on a mutually exclusive group is deprecated. These features were never - supported and do not always work correctly. The functions exist on the - API by accident through inheritance and will be removed in the future. - - .. deprecated-removed:: 3.14 + .. deprecated-removed:: 3.11 3.14 Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` - on a mutually exclusive group has been removed. + on a mutually exclusive group has been removed. These features were never + supported and did not always work correctly. The functions existed on the + API by accident through inheritance. Parser defaults From baed27b28c956710388614533f6e853370f61ca8 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 22:11:38 -0800 Subject: [PATCH 06/11] Fix refs in whatsnew --- Doc/whatsnew/3.14.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index c0ec367cded88b..c26cfe6c45c65d 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -641,12 +641,12 @@ argparse of :class:`!argparse.BooleanOptionalAction`. They were deprecated since 3.12. -* Calling :meth:`add_argument_group` on an argument group, and calling - :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` on - a mutually exclusive group have been removed. This nesting was never - supported, did not always work correctly, and existed in the API by - accident through inheritance. This functionality has been deprecated - since Python 3.11. +* Calling :meth:`~argparse.ArgumentParser.add_argument_group` on an argument + group, and calling :meth:`~argparse.ArgumentParser.add_argument_group` or + :meth:`~argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually + exclusive group have been removed. This nesting was never supported, did + not always work correctly, and existed in the API by accident through + inheritance. This functionality has been deprecated since Python 3.11. (Contributed by Savannah Ostrowski in :gh:`127186`.) ast From 813a2f55f799767571c61a096431e64511d1da5a Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 22:14:55 -0800 Subject: [PATCH 07/11] Fix references in news entry --- .../2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst index cd29c284884c47..883379a7127647 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst @@ -1 +1,6 @@ -Calling :meth:`add_argument_group` on an argument group, and calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` on a mutually exclusive group have been removed. This nesting was never supported, did not always work correctly, and existed in the API by accident through inheritance. This functionality has been deprecated since Python 3.11. +Calling :meth:`argparse.ArgumentParser.add_argument_group` on an argument group, +and calling :meth:`argparse.ArgumentParser.add_argument_group` or +:meth:`argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually +exclusive group have been removed. This nesting was never supported, did not +always work correctly, and existed in the API by accident through inheritance. +This functionality has been deprecated since Python 3.11. From 6c837ab6d1785edc26cd8d336b8d1fc39942e128 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 22 Nov 2024 22:16:04 -0800 Subject: [PATCH 08/11] precommit --- .../2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst index 883379a7127647..0e52de4d244a77 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst @@ -1,6 +1,6 @@ -Calling :meth:`argparse.ArgumentParser.add_argument_group` on an argument group, -and calling :meth:`argparse.ArgumentParser.add_argument_group` or -:meth:`argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually -exclusive group have been removed. This nesting was never supported, did not -always work correctly, and existed in the API by accident through inheritance. +Calling :meth:`argparse.ArgumentParser.add_argument_group` on an argument group, +and calling :meth:`argparse.ArgumentParser.add_argument_group` or +:meth:`argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually +exclusive group have been removed. This nesting was never supported, did not +always work correctly, and existed in the API by accident through inheritance. This functionality has been deprecated since Python 3.11. From d8357451b16e892ab49e6987c7016c08a724c927 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sat, 23 Nov 2024 19:09:09 -0800 Subject: [PATCH 09/11] Apply suggestions from code review Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> --- Lib/argparse.py | 4 ++-- Lib/test/test_argparse.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/argparse.py b/Lib/argparse.py index 5cc52c3490ddea..d24fa72e573d4f 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1709,7 +1709,7 @@ def _remove_action(self, action): self._group_actions.remove(action) def add_argument_group(self, *args, **kwargs): - raise ValueError('nested argument groups are not supported') + raise ValueError('argument groups cannot be nested') class _MutuallyExclusiveGroup(_ArgumentGroup): @@ -1731,7 +1731,7 @@ def _remove_action(self, action): self._group_actions.remove(action) def add_mutually_exclusive_group(self, **kwargs): - raise ValueError('nested mutually exclusive groups are not supported') + raise ValueError('mutually exclusive groups cannot be nested') def _prog_name(prog=None): if prog is not None: diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index c3b7d741f144b0..4f886d28bcb67d 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3310,7 +3310,7 @@ def test_nested_mutex_groups(self): g.add_argument("--spam") self.assertRaisesRegex(ValueError, 'nested mutually exclusive groups are not supported', - g.add_mutually_exclusive_group) + g.add_mutually_exclusive_group) class MEMixin(object): From 9708536290b2ce472f631f5b85663cbf0d1f427a Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sat, 23 Nov 2024 19:19:15 -0800 Subject: [PATCH 10/11] Reframe docs to focus on exception --- Doc/library/argparse.rst | 12 ++++++------ Doc/whatsnew/3.14.rst | 4 ++-- .../2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst index 230dfe7148d140..da4071dee34b8c 100644 --- a/Doc/library/argparse.rst +++ b/Doc/library/argparse.rst @@ -1927,9 +1927,9 @@ Argument groups in the usual "positional arguments" and "optional arguments" sections. .. deprecated-removed:: 3.11 3.14 - Calling :meth:`add_argument_group` on an argument group has been removed. - This feature was never supported and did not always work correctly. - The function existed on the API by accident through inheritance. + Calling :meth:`add_argument_group` on an argument group now raises an + exception. This nesting was never supported, often failed to work + correctly, and was unintentionally exposed through inheritance. .. deprecated:: 3.14 Passing prefix_chars_ to :meth:`add_argument_group` @@ -1994,9 +1994,9 @@ Mutual exclusion .. deprecated-removed:: 3.11 3.14 Calling :meth:`add_argument_group` or :meth:`add_mutually_exclusive_group` - on a mutually exclusive group has been removed. These features were never - supported and did not always work correctly. The functions existed on the - API by accident through inheritance. + on a mutually exclusive group now raises an exception. This nesting was + never supported, often failed to work correctly, and was unintentionally + exposed through inheritance. Parser defaults diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index c26cfe6c45c65d..2c1acb832080fc 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -644,8 +644,8 @@ argparse * Calling :meth:`~argparse.ArgumentParser.add_argument_group` on an argument group, and calling :meth:`~argparse.ArgumentParser.add_argument_group` or :meth:`~argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually - exclusive group have been removed. This nesting was never supported, did - not always work correctly, and existed in the API by accident through + exclusive group now raise exceptions. This nesting was never supported, + often failed to work correctly, and was unintentionally exposed through inheritance. This functionality has been deprecated since Python 3.11. (Contributed by Savannah Ostrowski in :gh:`127186`.) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst index 0e52de4d244a77..56b496bdf1e310 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2024-11-23-04-54-42.gh-issue-127133.WMoJjF.rst @@ -1,6 +1,6 @@ Calling :meth:`argparse.ArgumentParser.add_argument_group` on an argument group, and calling :meth:`argparse.ArgumentParser.add_argument_group` or :meth:`argparse.ArgumentParser.add_mutually_exclusive_group` on a mutually -exclusive group have been removed. This nesting was never supported, did not -always work correctly, and existed in the API by accident through inheritance. +exclusive group now raise exceptions. This nesting was never supported, often +failed to work correctly, and was unintentionally exposed through inheritance. This functionality has been deprecated since Python 3.11. From c55dbee846165f2774ebcedcc7c4b788e6abd0e5 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Sat, 23 Nov 2024 19:43:39 -0800 Subject: [PATCH 11/11] Fix test exception messages --- Lib/test/test_argparse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 4f886d28bcb67d..488a3a4ed20fac 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3001,7 +3001,7 @@ def test_nested_argument_group(self): parser = argparse.ArgumentParser() g = parser.add_argument_group() self.assertRaisesRegex(ValueError, - 'nested argument groups are not supported', + 'argument groups cannot be nested', g.add_argument_group) # =================== @@ -3309,7 +3309,7 @@ def test_nested_mutex_groups(self): g = parser.add_mutually_exclusive_group() g.add_argument("--spam") self.assertRaisesRegex(ValueError, - 'nested mutually exclusive groups are not supported', + 'mutually exclusive groups cannot be nested', g.add_mutually_exclusive_group) class MEMixin(object):