File: stop-using-private-argparse-functions.patch

package info (click to toggle)
python-cliff 4.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 696 kB
  • sloc: python: 5,215; makefile: 32; sh: 21
file content (41 lines) | stat: -rw-r--r-- 1,494 bytes parent folder | download
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)]