File: py312-syntax-warnings.patch

package info (click to toggle)
depthcharge-tools 0.6.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: python: 6,280; sh: 650; makefile: 12
file content (127 lines) | stat: -rw-r--r-- 5,134 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From: Colin Watson <cjwatson@debian.org>
Date: Sun, 10 Mar 2024 13:49:10 +0000
Subject: Fix syntax of Python regex escape sequences

This fixes `W605` warnings from `flake8`, and Python 3.12 now emits
`SyntaxWarning`s for these:

  https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

Forwarded: https://github.com/alpernebbi/depthcharge-tools/pull/9
Bug-Debian: https://bugs.debian.org/1078006
Last-Update: 2025-10-18
---
 depthcharge_tools/depthchargectl/__init__.py |  8 ++++----
 depthcharge_tools/utils/string.py            |  2 +-
 depthcharge_tools/utils/subprocess.py        |  2 +-
 update_config.py                             | 14 +++++++-------
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/depthcharge_tools/depthchargectl/__init__.py b/depthcharge_tools/depthchargectl/__init__.py
index 2d62fc6..547b130 100644
--- a/depthcharge_tools/depthchargectl/__init__.py
+++ b/depthcharge_tools/depthchargectl/__init__.py
@@ -77,16 +77,16 @@ class Board:
 
         # Try to detect non-regex values and extend them to match any
         # rev/sku, but if a rev/sku is given match only the given one.
-        if pattern and re.fullmatch("[\w,-]+", pattern):
+        if pattern and re.fullmatch(r"[\w,-]+", pattern):
             prefix, rev, sku = re.fullmatch(
-                "(.*?)(-rev\d+)?(-sku\d+)?",
+                r"(.*?)(-rev\d+)?(-sku\d+)?",
                 pattern,
             ).groups()
 
             pattern = "{}{}{}".format(
                 prefix,
-                rev or "(-rev\d+)?",
-                sku or "(-sku\d+)?",
+                rev or r"(-rev\d+)?",
+                sku or r"(-sku\d+)?",
             )
 
         if pattern:
diff --git a/depthcharge_tools/utils/string.py b/depthcharge_tools/utils/string.py
index 7e834c3..fa115cb 100644
--- a/depthcharge_tools/utils/string.py
+++ b/depthcharge_tools/utils/string.py
@@ -57,7 +57,7 @@ def parse_bytesize(val):
 
     try:
         s = str(val)
-        suffix = re.search("[a-zA-Z\s]*\Z", s)[0].strip()
+        suffix = re.search(r"[a-zA-Z\s]*\Z", s)[0].strip()
         number = s.rpartition(suffix)[0].strip()
         multiplier = bytesize_suffixes[suffix]
         return int(ast.literal_eval(number)) * multiplier
diff --git a/depthcharge_tools/utils/subprocess.py b/depthcharge_tools/utils/subprocess.py
index 58e5e07..55a1cac 100644
--- a/depthcharge_tools/utils/subprocess.py
+++ b/depthcharge_tools/utils/subprocess.py
@@ -402,7 +402,7 @@ class FdtgetRunner(ProcessRunner):
 
         # str.split takes too much memory
         def split(s):
-            for m in re.finditer("(\S*)\s", s):
+            for m in re.finditer(r"(\S*)\s", s):
                 yield m.group()
 
         if type in (None, int):
diff --git a/update_config.py b/update_config.py
index 58f1da0..29d6343 100644
--- a/update_config.py
+++ b/update_config.py
@@ -169,7 +169,7 @@ class update_config(
                 block["hwidmatch"] = None
 
             else:
-                m = re.match("^\^?\(?([0-9A-Z]+)[^0-9A-Za-z]", hwidmatch)
+                m = re.match(r"^\^?\(?([0-9A-Z]+)[^0-9A-Za-z]", hwidmatch)
                 if m:
                     codename = m.group(1).lower()
                 else:
@@ -340,7 +340,7 @@ class update_config(
                 elif line.startswith("string"):
                     type_ = lambda s: str.strip(s, "'\"")
 
-                m = re.match("default (\S+|\".+\")$", line)
+                m = re.match(r'default (\S+|".+")$', line)
                 try:
                     value = type_(m.group(1).strip("'\""))
                 except ValueError:
@@ -352,7 +352,7 @@ class update_config(
                         defaults[config][None] = value
                     value = None
 
-                m = re.match("default (\S+|\".+\") if ([0-9A-Z_]+)", line)
+                m = re.match(r'default (\S+|".+") if ([0-9A-Z_]+)', line)
                 try:
                     value = type_(m.group(1))
                     cond = m.group(2)
@@ -397,12 +397,12 @@ class update_config(
                 if config is None:
                     continue
 
-                m = re.match("select (\S+|\".+\")$", line)
+                m = re.match(r'select (\S+|".+")$', line)
                 if m:
                     value = m.group(1).strip("'\"")
                     selects[config][None].append(value)
 
-                m = re.match("select (\S+|\".+\") if ([0-9A-Z_]+)", line)
+                m = re.match(r'select (\S+|".+") if ([0-9A-Z_]+)', line)
                 if m:
                     value = m.group(1)
                     cond = m.group(2)
@@ -1076,8 +1076,8 @@ class update_config(
             board_c = board_c.read_text() if board_c.is_file() else ""
             if block.get("KERNEL_FIT", False):
                 m = re.search(
-                    'fit_(?:add|set)_compat(?:_by_rev)?\('
-                    '"([^"]+?)(?:-rev[^-]+|-sku[^-]+)*"',
+                    r'fit_(?:add|set)_compat(?:_by_rev)?\('
+                    r'"([^"]+?)(?:-rev[^-]+|-sku[^-]+)*"',
                     board_c,
                 )
                 if m: