bpo-26952: [argparse] clearer error when formatting an empty mutually… (GH-30099) (GH-30114)
(cherry picked from commit 86de99588db3beff964137f4fe27dd1077a09b35)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 9eed24c..b2db312 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -392,6 +392,9 @@ def _format_actions_usage(self, actions, groups):
group_actions = set()
inserts = {}
for group in groups:
+ if not group._group_actions:
+ raise ValueError(f'empty group {group}')
+
try:
start = actions.index(group._group_actions[0])
except ValueError: