diff mbox series

[layerindex-web,1/3] layerindex: use raw strings for regular expressions

Message ID 20261017183209.90930-1-tim.orling@konsulko.com
State New
Headers show
Series [layerindex-web,1/3] layerindex: use raw strings for regular expressions | expand

Commit Message

Tim Orling Oct. 17, 2026, 6:32 p.m. UTC
Fix the "invalid escape sequence" DeprecationWarnings reported by the
test suite in models.py, utils.py and forms.py. Python 3.12 turns these
into SyntaxWarnings and a future release will make them errors. The
patterns themselves are unchanged.

AI-Generated: Claude Opus 5.5
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/forms.py  | 2 +-
 layerindex/models.py | 2 +-
 layerindex/utils.py  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/layerindex/forms.py b/layerindex/forms.py
index b0ffc31..733adc2 100644
--- a/layerindex/forms.py
+++ b/layerindex/forms.py
@@ -136,7 +136,7 @@  class EditLayerForm(StyledModelForm):
     def clean_summary(self):
         # Compress whitespace and use only spaces
         summary = self.cleaned_data['summary'].strip()
-        summary = re.sub('\s+', ' ', summary)
+        summary = re.sub(r'\s+', ' ', summary)
         return summary
 
     def clean_layer_type(self):
diff --git a/layerindex/models.py b/layerindex/models.py
index 1a2ec60..a72a72b 100644
--- a/layerindex/models.py
+++ b/layerindex/models.py
@@ -278,7 +278,7 @@  class LayerBranch(models.Model):
             url = base_url.replace('%branch%', branchname)
             if path:
                 splitpath = path.split('/')
-                for match in re.findall('(%pathelement\[([0-9]*)(:[0-9]*)?\]%)', url):
+                for match in re.findall(r'(%pathelement\[([0-9]*)(:[0-9]*)?\]%)', url):
                     if match[1] == '':
                         start = None
                     else:
diff --git a/layerindex/utils.py b/layerindex/utils.py
index 6c0ad8f..7e7ebe4 100644
--- a/layerindex/utils.py
+++ b/layerindex/utils.py
@@ -528,7 +528,7 @@  def sanitise_html(html):
     return soup.renderContents()
 
 def squashspaces(string):
-    return re.sub("\s+", " ", string).strip()
+    return re.sub(r"\s+", " ", string).strip()
 
 def sha256_file(ifn):
     import hashlib