mackup icon indicating copy to clipboard operation
mackup copied to clipboard

SyntaxWarning: invalid escape sequence

Open imTHAI opened this issue 1 year ago • 2 comments

Hello,

I just reinstalled my Mac and did a restore:

$ mackup restore
/opt/homebrew/Cellar/mackup/0.8.41/libexec/lib/python3.13/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'
  name = re.findall('(<\S*?>)', source)[0]
/opt/homebrew/Cellar/mackup/0.8.41/libexec/lib/python3.13/site-packages/docopt.py:166: SyntaxWarning: invalid escape sequence '\['
  value = re.findall('\[default: (.*)\]', source, flags=re.I)
/opt/homebrew/Cellar/mackup/0.8.41/libexec/lib/python3.13/site-packages/docopt.py:207: SyntaxWarning: invalid escape sequence '\['
  matched = re.findall('\[default: (.*)\]', description, flags=re.I)
/opt/homebrew/Cellar/mackup/0.8.41/libexec/lib/python3.13/site-packages/docopt.py:456: SyntaxWarning: invalid escape sequence '\S'
  split = re.split('\n *(<\S+?>|-\S+?)', doc)[1:]

Do you know what's wrong? It is not the first time I use mackup after I install one of my Mac but it's the first time I get this error.

imTHAI avatar Nov 30 '24 13:11 imTHAI

Same issue here after upgrading via homebrew to version: 0.8.41

hjkatz avatar Dec 09 '24 16:12 hjkatz

Same. Related to https://github.com/lra/mackup/issues/1986. Not sure why that one was closed.

ngaloppo avatar Jan 03 '25 23:01 ngaloppo

@muzimuzhi posted what seems to so far be a working solution in that closed issue. I'm pasting it below for posterity.

diff --git a/lib/python3.12/site-packages/docopt.py b/lib/python3.12/site-packages/docoptnew.py
index 7b927e2..2a9590d 100644
--- a/lib/python3.12/site-packages/docopt.py
+++ b/lib/python3.12/site-packages/docoptnew.py
@@ -162,8 +162,8 @@ class Argument(ChildPattern):
 
     @classmethod
     def parse(class_, source):
-        name = re.findall('(<\S*?>)', source)[0]
-        value = re.findall('\[default: (.*)\]', source, flags=re.I)
+        name = re.findall(r'(<\S*?>)', source)[0]
+        value = re.findall(r'\[default: (.*)\]', source, flags=re.I)
         return class_(name, value[0] if value else None)
 
 
@@ -204,7 +204,7 @@ class Option(ChildPattern):
             else:
                 argcount = 1
         if argcount:
-            matched = re.findall('\[default: (.*)\]', description, flags=re.I)
+            matched = re.findall(r'\[default: (.*)\]', description, flags=re.I)
             value = matched[0] if matched else None
         return class_(short, long, argcount, value)
 
@@ -453,7 +453,7 @@ def parse_argv(tokens, options, options_first=False):
 
 def parse_defaults(doc):
     # in python < 2.7 you can't pass flags=re.MULTILINE
-    split = re.split('\n *(<\S+?>|-\S+?)', doc)[1:]
+    split = re.split(r'\n *(<\S+?>|-\S+?)', doc)[1:]
     split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])]
     options = [Option.parse(s) for s in split if s.startswith('-')]
     #arguments = [Argument.parse(s) for s in split if s.startswith('<')]

It looks like docopt hasn't been updated in 7 years.

JSouthGB avatar Mar 24 '25 02:03 JSouthGB

Thanks, fixed in https://github.com/lra/mackup/releases/tag/0.8.43

lra avatar Mar 30 '25 22:03 lra