summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-02-13 02:02:51 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2017-02-17 02:01:04 +0900
commite1da72b59c6ac5136f45709a0aa73dd5a296b2ff (patch)
tree71727a65c1fb7275a9477e06929c6f6638f64545
parentc4fc6113382969d41caa2e78cccfba2a5c7507a0 (diff)
downloadsphinx-git-e1da72b59c6ac5136f45709a0aa73dd5a296b2ff.tar.gz
Reduce DeprecationWarnings for regexp
-rw-r--r--Makefile2
-rw-r--r--sphinx/config.py3
-rw-r--r--sphinx/domains/python.py2
-rw-r--r--sphinx/domains/std.py2
-rw-r--r--sphinx/ext/autosummary/__init__.py4
-rw-r--r--sphinx/pycode/__init__.py2
-rw-r--r--sphinx/roles.py2
-rw-r--r--sphinx/util/__init__.py2
-rw-r--r--sphinx/util/docutils.py3
-rw-r--r--sphinx/util/nodes.py4
-rw-r--r--sphinx/util/rst.py2
-rw-r--r--sphinx/writers/latex.py8
-rw-r--r--sphinx/writers/manpage.py2
-rw-r--r--sphinx/writers/texinfo.py2
-rw-r--r--tests/etree13/ElementPath.py18
-rw-r--r--tests/etree13/ElementTree.py2
-rw-r--r--tests/test_build_html.py2
-rw-r--r--tests/test_build_latex.py16
-rw-r--r--tests/test_directive_code.py4
-rw-r--r--tests/test_domain_cpp.py12
-rw-r--r--tests/test_ext_graphviz.py16
-rw-r--r--tests/test_ext_inheritance_diagram.py2
-rw-r--r--tests/test_ext_math.py8
-rw-r--r--tests/test_util_rst.py4
-rwxr-xr-xutils/bump_version.py16
25 files changed, 71 insertions, 69 deletions
diff --git a/Makefile b/Makefile
index 9d28459fc..d14e6a3ae 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ DONT_CHECK = -i build -i dist -i sphinx/style/jquery.js \
all: clean-pyc clean-backupfiles style-check type-check test
style-check:
- @$(PYTHON) utils/check_sources.py $(DONT_CHECK) .
+ @PYTHONWARNINGS=all $(PYTHON) utils/check_sources.py $(DONT_CHECK) .
type-check:
mypy sphinx/
diff --git a/sphinx/config.py b/sphinx/config.py
index 12f206f96..3207b829b 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -171,7 +171,8 @@ class Config(object):
if getenv('SOURCE_DATE_EPOCH') is not None:
for k in ('copyright', 'epub_copyright'):
if k in config:
- config[k] = copyright_year_re.sub('\g<1>%s' % format_date('%Y'), config[k])
+ config[k] = copyright_year_re.sub(r'\g<1>%s' % format_date('%Y'),
+ config[k])
def check_types(self):
# type: () -> None
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 2467e85ef..25ce4c648 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -116,7 +116,7 @@ class PyXrefMixin(object):
def make_xrefs(self, rolename, domain, target, innernode=nodes.emphasis,
contnode=None):
# type: (unicode, unicode, unicode, nodes.Node, nodes.Node) -> List[nodes.Node]
- delims = '(\s*[\[\]\(\),](?:\s*or\s)?\s*|\s+or\s+)'
+ delims = r'(\s*[\[\]\(\),](?:\s*or\s)?\s*|\s+or\s+)'
delims_re = re.compile(delims)
sub_targets = re.split(delims, target)
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index abd02877c..cd518f713 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -47,7 +47,7 @@ logger = logging.getLogger(__name__)
# RE for option descriptions
option_desc_re = re.compile(r'((?:/|--|-|\+)?[^\s=]+)(=?\s*.*)')
# RE for grammar tokens
-token_re = re.compile('`(\w+)`', re.U)
+token_re = re.compile(r'`(\w+)`', re.U)
class GenericObject(ObjectDescription):
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py
index 8d521a74d..7bf5ad5b8 100644
--- a/sphinx/ext/autosummary/__init__.py
+++ b/sphinx/ext/autosummary/__init__.py
@@ -357,7 +357,7 @@ class Autosummary(Directive):
*items* is a list produced by :meth:`get_items`.
"""
table_spec = addnodes.tabular_col_spec()
- table_spec['spec'] = 'p{0.5\linewidth}p{0.5\linewidth}'
+ table_spec['spec'] = r'p{0.5\linewidth}p{0.5\linewidth}'
table = autosummary_table('')
real_table = nodes.table('', classes=['longtable'])
@@ -388,7 +388,7 @@ class Autosummary(Directive):
for name, sig, summary, real_name in items:
qualifier = 'obj'
if 'nosignatures' not in self.options:
- col1 = ':%s:`%s <%s>`\ %s' % (qualifier, name, real_name, rst.escape(sig)) # type: unicode # NOQA
+ col1 = ':%s:`%s <%s>`\\ %s' % (qualifier, name, real_name, rst.escape(sig)) # type: unicode # NOQA
else:
col1 = ':%s:`%s <%s>`' % (qualifier, name, real_name)
col2 = summary
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index bf8848305..d7c81e6f0 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -52,7 +52,7 @@ number2name.update(token.tok_name)
_eq = nodes.Leaf(token.EQUAL, '=')
-emptyline_re = re.compile('^\s*(#.*)?$')
+emptyline_re = re.compile(r'^\s*(#.*)?$')
class AttrDocVisitor(nodes.NodeVisitor):
diff --git a/sphinx/roles.py b/sphinx/roles.py
index 5dd815547..eb37b7ac7 100644
--- a/sphinx/roles.py
+++ b/sphinx/roles.py
@@ -293,7 +293,7 @@ def emph_literal_role(typ, rawtext, text, lineno, inliner,
return [retnode], []
-_abbr_re = re.compile('\((.*)\)$', re.S)
+_abbr_re = re.compile(r'\((.*)\)$', re.S)
def abbr_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index cd34139eb..997983f28 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -556,7 +556,7 @@ def encode_uri(uri):
def split_docinfo(text):
# type: (unicode) -> Sequence[unicode]
- docinfo_re = re.compile('\A((?:\s*:\w+:.*?\n(?:[ \t]+.*?\n)*)+)', re.M)
+ docinfo_re = re.compile('\\A((?:\\s*:\\w+:.*?\n(?:[ \\t]+.*?\n)*)+)', re.M)
result = docinfo_re.split(text, 1) # type: ignore
if len(result) == 1:
return '', result[0]
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py
index 38fdcde28..c50364fd9 100644
--- a/sphinx/util/docutils.py
+++ b/sphinx/util/docutils.py
@@ -21,7 +21,8 @@ from docutils.parsers.rst import directives, roles
from sphinx.util import logging
logger = logging.getLogger(__name__)
-report_re = re.compile('^(.+?:\d+): \((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\d+)?\) (.+?)\n?$')
+report_re = re.compile('^(.+?:\\d+): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/(\\d+)?\\) '
+ '(.+?)\n?$')
if False:
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index f5ddd036c..6bf47da1f 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -65,8 +65,8 @@ def apply_source_workaround(node):
if isinstance(node, nodes.term):
# strip classifier from rawsource of term
for classifier in reversed(node.parent.traverse(nodes.classifier)):
- node.rawsource = re.sub(
- '\s*:\s*%s' % re.escape(classifier.astext()), '', node.rawsource)
+ node.rawsource = re.sub(r'\s*:\s*%s' % re.escape(classifier.astext()),
+ '', node.rawsource)
# workaround: recommonmark-0.2.0 doesn't set rawsource attribute
if not node.rawsource:
diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py
index afb452f45..f49cb0c1d 100644
--- a/sphinx/util/rst.py
+++ b/sphinx/util/rst.py
@@ -11,7 +11,7 @@
import re
-symbols_re = re.compile('([!-/:-@\[-`{-~])')
+symbols_re = re.compile(r'([!-/:-@\[-`{-~])')
def escape(text):
diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py
index 72b6e527a..9d919713d 100644
--- a/sphinx/writers/latex.py
+++ b/sphinx/writers/latex.py
@@ -371,7 +371,7 @@ class Table(object):
This is what LaTeX calls the 'preamble argument' of the used table environment.
- .. note:: the ``\X`` column type specifier is defined in ``sphinx.sty``.
+ .. note:: the ``\\X`` column type specifier is defined in ``sphinx.sty``.
"""
if self.colspec:
return self.colspec
@@ -456,13 +456,13 @@ class TableCell(object):
def escape_abbr(text):
# type: (unicode) -> unicode
"""Adjust spacing after abbreviations."""
- return re.sub('\.(?=\s|$)', '.\\@', text)
+ return re.sub(r'\.(?=\s|$)', r'.\@', text)
def rstdim_to_latexdim(width_str):
# type: (unicode) -> unicode
"""Convert `width_str` with rst length to LaTeX length."""
- match = re.match('^(\d*\.?\d*)\s*(\S*)$', width_str)
+ match = re.match(r'^(\d*\.?\d*)\s*(\S*)$', width_str)
if not match:
raise ValueError
res = width_str
@@ -2244,7 +2244,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
def visit_line(self, node):
# type: (nodes.Node) -> None
- self.body.append('\item[] ')
+ self.body.append(r'\item[] ')
def depart_line(self, node):
# type: (nodes.Node) -> None
diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py
index c0ba28bbf..b7ed95f48 100644
--- a/sphinx/writers/manpage.py
+++ b/sphinx/writers/manpage.py
@@ -129,7 +129,7 @@ class ManualPageTranslator(BaseTranslator):
tmpl = (".TH \"%(title_upper)s\" \"%(manual_section)s\""
" \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n"
".SH NAME\n"
- "%(title)s \- %(subtitle)s\n")
+ "%(title)s \\- %(subtitle)s\n")
return tmpl % self._docinfo
def visit_start_of_file(self, node):
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py
index a6908d113..c3cacd3e2 100644
--- a/sphinx/writers/texinfo.py
+++ b/sphinx/writers/texinfo.py
@@ -469,7 +469,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
def tex_image_length(self, width_str):
# type: (unicode) -> unicode
- match = re.match('(\d*\.?\d*)\s*(\S*)', width_str)
+ match = re.match(r'(\d*\.?\d*)\s*(\S*)', width_str)
if not match:
# fallback
return width_str
diff --git a/tests/etree13/ElementPath.py b/tests/etree13/ElementPath.py
index d26a0d7a0..8cf1ab578 100644
--- a/tests/etree13/ElementPath.py
+++ b/tests/etree13/ElementPath.py
@@ -52,15 +52,15 @@
import re
xpath_tokenizer = re.compile(
- "("
- "'[^']*'|\"[^\"]*\"|"
- "::|"
- "//?|"
- "\.\.|"
- "\(\)|"
- "[/.*:\[\]\(\)@=])|"
- "((?:\{[^}]+\})?[^/:\[\]\(\)@=\s]+)|"
- "\s+"
+ r"("
+ r"'[^']*'|\"[^\"]*\"|"
+ r"::|"
+ r"//?|"
+ r"\.\.|"
+ r"\(\)|"
+ r"[/.*:\[\]\(\)@=])|"
+ r"((?:\{[^}]+\})?[^/:\[\]\(\)@=\s]+)|"
+ r"\s+"
).findall
def prepare_tag(next, token):
diff --git a/tests/etree13/ElementTree.py b/tests/etree13/ElementTree.py
index 0dd12ddb6..134abf313 100644
--- a/tests/etree13/ElementTree.py
+++ b/tests/etree13/ElementTree.py
@@ -976,7 +976,7 @@ def _serialize_text(write, elem, encoding):
# invalid.
def register_namespace(prefix, uri):
- if re.match("ns\d+$", prefix):
+ if re.match(r"ns\d+$", prefix):
raise ValueError("Prefix format reserved for internal use")
for k, v in _namespace_map.items():
if k == uri or v == prefix:
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index 2750ae29a..068390471 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -346,7 +346,7 @@ def test_static_output(app):
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
'perl'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-p']/code/span",
- '\+p'),
+ '\\+p'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-objc']/code/span",
'--ObjC\\+\\+'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-plugin-option']/code/span",
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index 9a91bf0b5..cd040eb1b 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -482,9 +482,9 @@ def test_footnote(app, status, warning):
assert '\\caption{Table caption \\sphinxfootnotemark[4]' in result
assert 'name \\sphinxfootnotemark[5]' in result
assert ('\\end{threeparttable}\n\\par\n\\endgroup\n%\n'
- '\\begin{footnotetext}[4]\sphinxAtStartFootnote\n'
+ '\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
'footnotes in table caption\n%\n\\end{footnotetext}%\n'
- '\\begin{footnotetext}[5]\sphinxAtStartFootnote\n'
+ '\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n'
'footnotes in table\n%\n\\end{footnotetext}') in result
@@ -507,18 +507,18 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
'%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n'
'Footnote in section\n%\n\\end{footnotetext}') in result
assert ('\\caption{This is the figure caption with a footnote to '
- '\\sphinxfootnotemark[6].}\label{\\detokenize{index:id27}}\end{figure}\n'
+ '\\sphinxfootnotemark[6].}\\label{\\detokenize{index:id27}}\\end{figure}\n'
'%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n'
'Footnote in caption\n%\n\\end{footnotetext}')in result
assert ('\\caption{footnote \\sphinxfootnotemark[7] '
'in caption of normal table}\\label{\\detokenize{index:id28}}') in result
assert ('\\caption{footnote \\sphinxfootnotemark[8] '
- 'in caption \sphinxfootnotemark[9] of longtable}') in result
- assert ('\end{longtable}\n%\n\\begin{footnotetext}[8]'
- '\sphinxAtStartFootnote\n'
+ 'in caption \\sphinxfootnotemark[9] of longtable}') in result
+ assert ('\\end{longtable}\n%\n\\begin{footnotetext}[8]'
+ '\\sphinxAtStartFootnote\n'
'Foot note in longtable\n%\n\\end{footnotetext}' in result)
assert ('This is a reference to the code-block in the footnote:\n'
- '{\hyperref[\\detokenize{index:codeblockinfootnote}]'
+ '{\\hyperref[\\detokenize{index:codeblockinfootnote}]'
'{\\sphinxcrossref{\\DUrole{std,std-ref}{I am in a footnote}}}}') in result
assert ('&\nThis is one more footnote with some code in it '
'\\sphinxfootnotemark[10].\n\\\\') in result
@@ -855,7 +855,7 @@ def test_latex_table_tabulars(app, status, warning):
# table having :align: option (tabular)
table = tables['table having :align: option (tabular)']
assert ('\\begingroup\n\\raggedright\n'
- '\\begin{tabular}{|\X{30}{100}|\X{70}{100}|}\n' in table)
+ '\\begin{tabular}{|\\X{30}{100}|\\X{70}{100}|}\n' in table)
assert ('\\hline\n\\end{tabular}\n\\par\n\\endgroup' in table)
# table with tabularcolumn
diff --git a/tests/test_directive_code.py b/tests/test_directive_code.py
index 4ebe937d8..5c1bacfa8 100644
--- a/tests/test_directive_code.py
+++ b/tests/test_directive_code.py
@@ -67,7 +67,7 @@ def test_code_block_caption_latex(app, status, warning):
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstyleemphasis{test} rb}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id1}}}'
- link = '\hyperref[\\detokenize{caption:name-test-rb}]' \
+ link = '\\hyperref[\\detokenize{caption:name-test-rb}]' \
'{Listing \\ref{\\detokenize{caption:name-test-rb}}}'
assert caption in latex
assert label in latex
@@ -263,7 +263,7 @@ def test_literalinclude_caption_latex(app, status, warning):
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
caption = '\\sphinxSetupCaptionForVerbatim{caption \\sphinxstylestrong{test} py}'
label = '\\def\\sphinxLiteralBlockLabel{\\label{\\detokenize{caption:id2}}}'
- link = '\hyperref[\\detokenize{caption:name-test-py}]' \
+ link = '\\hyperref[\\detokenize{caption:name-test-py}]' \
'{Listing \\ref{\\detokenize{caption:name-test-py}}}'
assert caption in latex
assert label in latex
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 00ffd484e..4ff8a11f0 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -520,12 +520,12 @@ def test_build_domain_cpp_with_add_function_parentheses_is_True(app, status, war
('', 'MyEnum')
]
parenPatterns = [
- ('ref function without parens ', 'paren_1\(\)'),
- ('ref function with parens ', 'paren_2\(\)'),
+ ('ref function without parens ', r'paren_1\(\)'),
+ ('ref function with parens ', r'paren_2\(\)'),
('ref function without parens, explicit title ', 'paren_3_title'),
('ref function with parens, explicit title ', 'paren_4_title'),
- ('ref op call without parens ', 'paren_5::operator\(\)\(\)'),
- ('ref op call with parens ', 'paren_6::operator\(\)\(\)'),
+ ('ref op call without parens ', r'paren_5::operator\(\)\(\)'),
+ ('ref op call with parens ', r'paren_6::operator\(\)\(\)'),
('ref op call without parens, explicit title ', 'paren_7_title'),
('ref op call with parens, explicit title ', 'paren_8_title')
]
@@ -566,8 +566,8 @@ def test_build_domain_cpp_with_add_function_parentheses_is_False(app, status, wa
('ref function with parens ', 'paren_2'),
('ref function without parens, explicit title ', 'paren_3_title'),
('ref function with parens, explicit title ', 'paren_4_title'),
- ('ref op call without parens ', 'paren_5::operator\(\)'),
- ('ref op call with parens ', 'paren_6::operator\(\)'),
+ ('ref op call without parens ', r'paren_5::operator\(\)'),
+ ('ref op call with parens ', r'paren_6::operator\(\)'),
('ref op call without parens, explicit title ', 'paren_7_title'),
('ref op call with parens, explicit title ', 'paren_8_title')
]
diff --git a/tests/test_ext_graphviz.py b/tests/test_ext_graphviz.py
index 45850f3ce..1c31e8eaf 100644
--- a/tests/test_ext_graphviz.py
+++ b/tests/test_ext_graphviz.py
@@ -20,8 +20,8 @@ def test_graphviz_html(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').text()
- html = ('<div class="figure" .*?>\s*<img .*?/>\s*<p class="caption">'
- '<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
+ html = (r'<div class="figure" .*?>\s*<img .*?/>\s*<p class="caption">'
+ r'<span class="caption-text">caption of graph</span>.*</p>\s*</div>')
assert re.search(html, content, re.S)
html = 'Hello <img .*?/>\n graphviz world'
@@ -30,8 +30,8 @@ def test_graphviz_html(app, status, warning):
html = '<img src=".*?" alt="digraph {\n bar -&gt; baz\n}" />'
assert re.search(html, content, re.M)
- html = ('<div class="figure align-right" .*?>\s*<img .*?/>\s*<p class="caption">'
- '<span class="caption-text">on right</span>.*</p>\s*</div>')
+ html = (r'<div class="figure align-right" .*?>\s*<img .*?/>\s*<p class="caption">'
+ r'<span class="caption-text">on right</span>.*</p>\s*</div>')
assert re.search(html, content, re.S)
@@ -41,16 +41,16 @@ def test_graphviz_latex(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'SphinxTests.tex').text()
- macro = ('\\\\begin{figure}\[htbp\]\n\\\\centering\n\\\\capstart\n\n'
- '\\\\includegraphics{graphviz-\w+.pdf}\n'
+ macro = ('\\\\begin{figure}\\[htbp\\]\n\\\\centering\n\\\\capstart\n\n'
+ '\\\\includegraphics{graphviz-\\w+.pdf}\n'
'\\\\caption{caption of graph}\\\\label{.*}\\\\end{figure}')
assert re.search(macro, content, re.S)
- macro = 'Hello \\\\includegraphics{graphviz-\w+.pdf} graphviz world'
+ macro = 'Hello \\\\includegraphics{graphviz-\\w+.pdf} graphviz world'
assert re.search(macro, content, re.S)
macro = ('\\\\begin{wrapfigure}{r}{0pt}\n\\\\centering\n'
- '\\\\includegraphics{graphviz-\w+.pdf}\n'
+ '\\\\includegraphics{graphviz-\\w+.pdf}\n'
'\\\\caption{on right}\\\\label{.*}\\\\end{wrapfigure}')
assert re.search(macro, content, re.S)
diff --git a/tests/test_ext_inheritance_diagram.py b/tests/test_ext_inheritance_diagram.py
index 3ce4b23a5..731dc54ca 100644
--- a/tests/test_ext_inheritance_diagram.py
+++ b/tests/test_ext_inheritance_diagram.py
@@ -24,7 +24,7 @@ def test_inheritance_diagram_html(app, status, warning):
content = (app.outdir / 'index.html').text()
pattern = ('<div class="figure" id="id1">\n'
- '<img src="_images/inheritance-\w+.png" alt="Inheritance diagram of test.Foo" '
+ '<img src="_images/inheritance-\\w+.png" alt="Inheritance diagram of test.Foo" '
'class="inheritance"/>\n<p class="caption"><span class="caption-text">'
'Test Foo!</span><a class="headerlink" href="#id1" '
'title="Permalink to this image">\xb6</a></p>')
diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py
index 3a2c4df45..3cbb534e9 100644
--- a/tests/test_ext_math.py
+++ b/tests/test_ext_math.py
@@ -45,8 +45,8 @@ def test_imgmath_png(app, status, warning):
raise SkipTest('dvipng command "dvipng" is not available')
content = (app.outdir / 'index.html').text()
- html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.png"'
- '\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
+ html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.png"'
+ r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
assert re.search(html, content, re.S)
@@ -61,8 +61,8 @@ def test_imgmath_svg(app, status, warning):
raise SkipTest('dvisvgm command "dvisvgm" is not available')
content = (app.outdir / 'index.html').text()
- html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
- '\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
+ html = (r'<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
+ r'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
assert re.search(html, content, re.S)
diff --git a/tests/test_util_rst.py b/tests/test_util_rst.py
index 72cd87fe8..b4ce955f4 100644
--- a/tests/test_util_rst.py
+++ b/tests/test_util_rst.py
@@ -12,5 +12,5 @@ from sphinx.util.rst import escape
def test_escape():
- assert escape(':ref:`id`') == '\:ref\:\`id\`'
- assert escape('footnote [#]_') == 'footnote \[\#\]\_'
+ assert escape(':ref:`id`') == r'\:ref\:\`id\`'
+ assert escape('footnote [#]_') == r'footnote \[\#\]\_'
diff --git a/utils/bump_version.py b/utils/bump_version.py
index 617c33c0c..95db65ea7 100755
--- a/utils/bump_version.py
+++ b/utils/bump_version.py
@@ -29,9 +29,9 @@ def bump_version(path, version_info):
with open(path, 'r+') as f:
body = f.read()
- body = re.sub("(?<=__version__ = ')[^']+", version, body)
- body = re.sub("(?<=__released__ = ')[^']+", release, body)
- body = re.sub("(?<=version_info = )\(.*\)", str(version_info), body)
+ body = re.sub(r"(?<=__version__ = ')[^']+", version, body)
+ body = re.sub(r"(?<=__released__ = ')[^']+", release, body)
+ body = re.sub(r"(?<=version_info = )\(.*\)", str(version_info), body)
f.seek(0)
f.truncate(0)
@@ -39,23 +39,23 @@ def bump_version(path, version_info):
def parse_version(version):
- matched = re.search('^(\d+)\.(\d+)$', version)
+ matched = re.search(r'^(\d+)\.(\d+)$', version)
if matched:
major, minor = matched.groups()
return (int(major), int(minor), 0, 'final', 0)
- matched = re.search('^(\d+)\.(\d+)\.(\d+)$', version)
+ matched = re.search(r'^(\d+)\.(\d+)\.(\d+)$', version)
if matched:
major, minor, rev = matched.groups()
return (int(major), int(minor), int(rev), 'final', 0)
- matched = re.search('^(\d+)\.(\d+)\s*(a|b|alpha|beta)(\d+)$', version)
+ matched = re.search(r'^(\d+)\.(\d+)\s*(a|b|alpha|beta)(\d+)$', version)
if matched:
major, minor, typ, relver = matched.groups()
release = RELEASE_TYPE.get(typ, typ)
return (int(major), int(minor), 0, release, int(relver))
- matched = re.search('^(\d+)\.(\d+)\.(\d+)\s*(a|b|alpha|beta)(\d+)$', version)
+ matched = re.search(r'^(\d+)\.(\d+)\.(\d+)\s*(a|b|alpha|beta)(\d+)$', version)
if matched:
major, minor, rev, typ, relver = matched.groups()
release = RELEASE_TYPE.get(typ, typ)
@@ -90,7 +90,7 @@ class Changes(object):
def fetch_version(self):
with open(self.path) as f:
version = f.readline().strip()
- matched = re.search('^Release (.*) \((.*)\)$', version)
+ matched = re.search(r'^Release (.*) \((.*)\)$', version)
if matched is None:
raise RuntimeError('Unknown CHANGES format: %s' % version)