From 2cccf225af1abf0cec8932b5feaf29120a30ca43 2018-10-27 20:03:17
From: Matthias Bussonnier <bussonniermatthias@gmail.com>
Date: 2018-10-27 20:03:17
Subject: [PATCH] fix some other syntax warnings

---

diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py
index eeb39a4..9b14bf7 100644
--- a/IPython/core/completerlib.py
+++ b/IPython/core/completerlib.py
@@ -185,7 +185,7 @@ def try_import(mod: str, only_modules=False) -> List[str]:
 #-----------------------------------------------------------------------------
 
 def quick_completer(cmd, completions):
-    """ Easily create a trivial completer for a command.
+    r""" Easily create a trivial completer for a command.
 
     Takes either a list of completions, or all completions in string (that will
     be split on whitespace).
diff --git a/IPython/core/display.py b/IPython/core/display.py
index d2a29fc..db75659 100644
--- a/IPython/core/display.py
+++ b/IPython/core/display.py
@@ -710,7 +710,7 @@ class Markdown(TextDisplayObject):
 class Math(TextDisplayObject):
 
     def _repr_latex_(self):
-        s = "$\displaystyle %s$" % self.data.strip('$')
+        s = r"$\displaystyle %s$" % self.data.strip('$')
         if self.metadata:
             return s, deepcopy(self.metadata)
         else:
diff --git a/IPython/core/inputtransformer2.py b/IPython/core/inputtransformer2.py
index 996a4f0..0bf22a1 100644
--- a/IPython/core/inputtransformer2.py
+++ b/IPython/core/inputtransformer2.py
@@ -78,7 +78,7 @@ ipython_prompt = PromptStripper(re.compile(r'^(In \[\d+\]: |\s*\.{3,}: ?)'))
 def cell_magic(lines):
     if not lines or not lines[0].startswith('%%'):
         return lines
-    if re.match('%%\w+\?', lines[0]):
+    if re.match(r'%%\w+\?', lines[0]):
         # This case will be handled by help_end
         return lines
     magic_name, _, first_line = lines[0][2:-1].partition(' ')
@@ -116,7 +116,7 @@ def find_end_of_continued_line(lines, start_line: int):
     return end_line
 
 def assemble_continued_line(lines, start: Tuple[int, int], end_line: int):
-    """Assemble a single line from multiple continued line pieces
+    r"""Assemble a single line from multiple continued line pieces
 
     Continued lines are lines ending in ``\``, and the line following the last
     ``\`` in the block.
diff --git a/IPython/core/magics/namespace.py b/IPython/core/magics/namespace.py
index 343db92..7e644cf 100644
--- a/IPython/core/magics/namespace.py
+++ b/IPython/core/magics/namespace.py
@@ -49,7 +49,7 @@ class NamespaceMagics(Magics):
         # We need to detect if we got called as 'pinfo pinfo foo', which can
         # happen if the user types 'pinfo foo?' at the cmd line.
         pinfo,qmark1,oname,qmark2 = \
-               re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
+               re.match(r'(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
         if pinfo or qmark1 or qmark2:
             detail_level = 1
         if "*" in oname:
diff --git a/IPython/lib/demo.py b/IPython/lib/demo.py
index 26e4fad..272db22 100644
--- a/IPython/lib/demo.py
+++ b/IPython/lib/demo.py
@@ -197,7 +197,7 @@ def re_mark(mark):
 
 class Demo(object):
 
-    re_stop     = re_mark('-*\s?stop\s?-*')
+    re_stop     = re_mark(r'-*\s?stop\s?-*')
     re_silent   = re_mark('silent')
     re_auto     = re_mark('auto')
     re_auto_all = re_mark('auto_all')
diff --git a/IPython/lib/latextools.py b/IPython/lib/latextools.py
index 4de9ecc..b56b360 100644
--- a/IPython/lib/latextools.py
+++ b/IPython/lib/latextools.py
@@ -179,7 +179,7 @@ def genelatex(body, wrap):
         yield u'$${0}$$'.format(body)
     else:
         yield body
-    yield u'\end{document}'
+    yield u'\\end{document}'
 
 
 _data_uri_template_png = u"""<img src="data:image/png;base64,%s" alt=%s />"""
diff --git a/IPython/lib/lexers.py b/IPython/lib/lexers.py
index a8c8710..1677054 100644
--- a/IPython/lib/lexers.py
+++ b/IPython/lib/lexers.py
@@ -494,7 +494,7 @@ class IPythonConsoleLexer(Lexer):
             yield token
 
 class IPyLexer(Lexer):
-    """
+    r"""
     Primary lexer for all IPython-like code.
 
     This is a simple helper lexer.  If the first line of the text begins with
diff --git a/IPython/testing/ipunittest.py b/IPython/testing/ipunittest.py
index aab3861..139c305 100644
--- a/IPython/testing/ipunittest.py
+++ b/IPython/testing/ipunittest.py
@@ -63,8 +63,8 @@ class IPython2PythonConverter(object):
         self.rout = re.compile(r'Out\[\d+\]: \s*?\n?')
         self.pyps1 = '>>> '
         self.pyps2 = '... '
-        self.rpyps1 = re.compile ('(\s*%s)(.*)$' % self.pyps1)
-        self.rpyps2 = re.compile ('(\s*%s)(.*)$' % self.pyps2)
+        self.rpyps1 = re.compile (r'(\s*%s)(.*)$' % self.pyps1)
+        self.rpyps2 = re.compile (r'(\s*%s)(.*)$' % self.pyps2)
 
     def __call__(self, ds):
         """Convert IPython prompts to python ones in a string."""