1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Description: Stop using private argparse functions
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1127523
Forwarded: no
Last-Update: 2026-02-12
Index: python-cliff/cliff/sphinxext.py
===================================================================
--- python-cliff.orig/cliff/sphinxext.py
+++ python-cliff/cliff/sphinxext.py
@@ -84,12 +84,25 @@ def _format_usage(parser: argparse.Argum
re.VERBOSE,
)
- opt_usage = fmt._format_actions_usage(optionals, groups)
- pos_usage = fmt._format_actions_usage(positionals, groups)
+ if hasattr(fmt, "_format_actions_usage"):
+ # Python <= 3.13
+ opt_usage = fmt._format_actions_usage(optionals, groups)
+ pos_usage = fmt._format_actions_usage(positionals, groups)
- opt_parts = part_regexp.findall(opt_usage)
- pos_parts = part_regexp.findall(pos_usage)
- parts = opt_parts + pos_parts
+ opt_parts = part_regexp.findall(opt_usage)
+ pos_parts = part_regexp.findall(pos_usage)
+ parts = opt_parts + pos_parts
+ else:
+ # Python >= 3.14
+ usage = parser.format_usage().strip()
+
+ if usage.lower().startswith("usage:"):
+ usage = usage.split(":", 1)[1].strip()
+
+ if usage.startswith(parser.prog):
+ usage = usage[len(parser.prog):].lstrip()
+
+ parts = part_regexp.findall(usage)
if len(' '.join([parser.prog] + parts)) < 72:
return [' '.join([parser.prog] + parts)]
|