summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-01-09 01:19:59 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2022-01-09 01:19:59 +0900
commitb90a52c93cae5f7f5273fc1ac9caf7e49861e11c (patch)
tree5a06b060d1ebd48efd3ceac78a59ad572f8d6e85
parent1cb47e0347b598bd79a7dcbfa70db35d0560952b (diff)
parent87eda92a52e107e9243acac055037c3d6e50819c (diff)
downloadsphinx-git-b90a52c93cae5f7f5273fc1ac9caf7e49861e11c.tar.gz
Merge branch '4.x'
-rw-r--r--setup.py2
-rw-r--r--sphinx/directives/patches.py6
-rw-r--r--sphinx/locale/__init__.py2
-rw-r--r--sphinx/util/requests.py4
-rw-r--r--tests/test_domain_py.py6
-rw-r--r--tests/test_domain_std.py4
-rw-r--r--tests/test_markup.py2
-rw-r--r--tests/test_smartquotes.py7
-rw-r--r--tests/test_util_nodes.py14
-rw-r--r--tests/test_versioning.py18
-rw-r--r--tox.ini4
11 files changed, 36 insertions, 33 deletions
diff --git a/setup.py b/setup.py
index e222d2430..ccadd59f4 100644
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,7 @@ extras_require = {
'lint': [
'flake8>=3.5.0',
'isort',
- 'mypy>=0.930',
+ 'mypy>=0.931',
'docutils-stubs',
"types-typed-ast",
"types-requests",
diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py
index d4d498725..d76bb74c7 100644
--- a/sphinx/directives/patches.py
+++ b/sphinx/directives/patches.py
@@ -9,7 +9,7 @@
import os
import warnings
from os import path
-from typing import TYPE_CHECKING, Any, Dict, List, Tuple, cast
+from typing import TYPE_CHECKING, Any, Dict, List, Sequence, Tuple, cast
from docutils import nodes
from docutils.nodes import Node, make_id, system_message
@@ -68,7 +68,7 @@ class Figure(images.Figure):
class Meta(MetaBase, SphinxDirective):
- def run(self) -> List[Node]:
+ def run(self) -> Sequence[Node]:
result = super().run()
for node in result:
# for docutils-0.17 or older. Since docutils-0.18, patching is no longer needed
@@ -83,7 +83,7 @@ class Meta(MetaBase, SphinxDirective):
# docutils' meta nodes aren't picklable because the class is nested
meta.__class__ = addnodes.meta
- return result # type: ignore
+ return result
class RSTTable(tables.RSTTable):
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index 8fc6c1519..5378da0a3 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -4,7 +4,7 @@
Locale utilities.
- :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2022 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/sphinx/util/requests.py b/sphinx/util/requests.py
index 43ce64f10..0a9d63489 100644
--- a/sphinx/util/requests.py
+++ b/sphinx/util/requests.py
@@ -24,10 +24,10 @@ try:
except ImportError:
try:
# for Debian-jessie
- from urllib3.exceptions import InsecureRequestWarning # type: ignore
+ from urllib3.exceptions import InsecureRequestWarning
except ImportError:
# for requests < 2.4.0
- InsecureRequestWarning = None # type: ignore
+ InsecureRequestWarning = None
useragent_header = [('User-Agent',
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index ec4a0b8a7..de544d25d 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -79,7 +79,7 @@ def test_domain_py_xrefs(app, status, warning):
assert_node(node, **attributes)
doctree = app.env.get_doctree('roles')
- refnodes = list(doctree.traverse(pending_xref))
+ refnodes = list(doctree.findall(pending_xref))
assert_refnode(refnodes[0], None, None, 'TopLevel', 'class')
assert_refnode(refnodes[1], None, None, 'top_level', 'meth')
assert_refnode(refnodes[2], None, 'NestedParentA', 'child_1', 'meth')
@@ -97,7 +97,7 @@ def test_domain_py_xrefs(app, status, warning):
assert len(refnodes) == 13
doctree = app.env.get_doctree('module')
- refnodes = list(doctree.traverse(pending_xref))
+ refnodes = list(doctree.findall(pending_xref))
assert_refnode(refnodes[0], 'module_a.submodule', None,
'ModTopLevel', 'class')
assert_refnode(refnodes[1], 'module_a.submodule', 'ModTopLevel',
@@ -126,7 +126,7 @@ def test_domain_py_xrefs(app, status, warning):
assert len(refnodes) == 16
doctree = app.env.get_doctree('module_option')
- refnodes = list(doctree.traverse(pending_xref))
+ refnodes = list(doctree.findall(pending_xref))
print(refnodes)
print(refnodes[0])
print(refnodes[1])
diff --git a/tests/test_domain_std.py b/tests/test_domain_std.py
index 14c2bd3e2..1428bce31 100644
--- a/tests/test_domain_std.py
+++ b/tests/test_domain_std.py
@@ -36,7 +36,7 @@ def test_process_doc_handle_figure_caption():
ids={'testid': figure_node},
citation_refs={},
)
- document.traverse.return_value = []
+ document.findall.return_value = []
domain = StandardDomain(env)
if 'testname' in domain.data['labels']:
@@ -60,7 +60,7 @@ def test_process_doc_handle_table_title():
ids={'testid': table_node},
citation_refs={},
)
- document.traverse.return_value = []
+ document.findall.return_value = []
domain = StandardDomain(env)
if 'testname' in domain.data['labels']:
diff --git a/tests/test_markup.py b/tests/test_markup.py
index fbd4e20cc..e1e01491a 100644
--- a/tests/test_markup.py
+++ b/tests/test_markup.py
@@ -67,7 +67,7 @@ def parse(new_document):
parser = RstParser()
parser.parse(rst, document)
SphinxSmartQuotes(document, startnode=None).apply()
- for msg in document.traverse(nodes.system_message):
+ for msg in list(document.findall(nodes.system_message)):
if msg['level'] == 1:
msg.replace_self([])
return document
diff --git a/tests/test_smartquotes.py b/tests/test_smartquotes.py
index a46e667ca..bd8216167 100644
--- a/tests/test_smartquotes.py
+++ b/tests/test_smartquotes.py
@@ -11,6 +11,8 @@
import pytest
from html5lib import HTMLParser
+from sphinx.util import docutils
+
@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True)
def test_basic(app, status, warning):
@@ -51,7 +53,10 @@ def test_man_builder(app, status, warning):
app.build()
content = (app.outdir / 'python.1').read_text()
- assert '\\-\\- "Sphinx" is a tool that makes it easy ...' in content
+ if docutils.__version_info__ > (0, 18):
+ assert r'\-\- \(dqSphinx\(dq is a tool that makes it easy ...' in content
+ else:
+ assert r'\-\- "Sphinx" is a tool that makes it easy ...' in content
@pytest.mark.sphinx(buildername='latex', testroot='smartquotes', freshenv=True)
diff --git a/tests/test_util_nodes.py b/tests/test_util_nodes.py
index 1e08244cc..fe0a278e6 100644
--- a/tests/test_util_nodes.py
+++ b/tests/test_util_nodes.py
@@ -60,31 +60,31 @@ def test_NodeMatcher():
# search by node class
matcher = NodeMatcher(nodes.paragraph)
- assert len(list(doctree.traverse(matcher))) == 3
+ assert len(list(doctree.findall(matcher))) == 3
# search by multiple node classes
matcher = NodeMatcher(nodes.paragraph, nodes.literal_block)
- assert len(list(doctree.traverse(matcher))) == 4
+ assert len(list(doctree.findall(matcher))) == 4
# search by node attribute
matcher = NodeMatcher(block=1)
- assert len(list(doctree.traverse(matcher))) == 1
+ assert len(list(doctree.findall(matcher))) == 1
# search by node attribute (Any)
matcher = NodeMatcher(block=Any)
- assert len(list(doctree.traverse(matcher))) == 3
+ assert len(list(doctree.findall(matcher))) == 3
# search by both class and attribute
matcher = NodeMatcher(nodes.paragraph, block=Any)
- assert len(list(doctree.traverse(matcher))) == 2
+ assert len(list(doctree.findall(matcher))) == 2
# mismatched
matcher = NodeMatcher(nodes.title)
- assert len(list(doctree.traverse(matcher))) == 0
+ assert len(list(doctree.findall(matcher))) == 0
# search with Any does not match to Text node
matcher = NodeMatcher(blah=Any)
- assert len(list(doctree.traverse(matcher))) == 0
+ assert len(list(doctree.findall(matcher))) == 0
@pytest.mark.parametrize(
diff --git a/tests/test_versioning.py b/tests/test_versioning.py
index 9961fe464..4de8331aa 100644
--- a/tests/test_versioning.py
+++ b/tests/test_versioning.py
@@ -70,16 +70,16 @@ def test_picklablility():
copy.settings.warning_stream = None
copy.settings.env = None
copy.settings.record_dependencies = None
- for metanode in copy.traverse(meta):
+ for metanode in copy.findall(meta):
metanode.__class__ = addnodes.meta
loaded = pickle.loads(pickle.dumps(copy, pickle.HIGHEST_PROTOCOL))
- assert all(getattr(n, 'uid', False) for n in loaded.traverse(is_paragraph))
+ assert all(getattr(n, 'uid', False) for n in loaded.findall(is_paragraph))
def test_modified():
modified = doctrees['modified']
new_nodes = list(merge_doctrees(original, modified, is_paragraph))
- uids = [n.uid for n in modified.traverse(is_paragraph)]
+ uids = [n.uid for n in modified.findall(is_paragraph)]
assert not new_nodes
assert original_uids == uids
@@ -87,7 +87,7 @@ def test_modified():
def test_added():
added = doctrees['added']
new_nodes = list(merge_doctrees(original, added, is_paragraph))
- uids = [n.uid for n in added.traverse(is_paragraph)]
+ uids = [n.uid for n in added.findall(is_paragraph)]
assert len(new_nodes) == 1
assert original_uids == uids[:-1]
@@ -95,7 +95,7 @@ def test_added():
def test_deleted():
deleted = doctrees['deleted']
new_nodes = list(merge_doctrees(original, deleted, is_paragraph))
- uids = [n.uid for n in deleted.traverse(is_paragraph)]
+ uids = [n.uid for n in deleted.findall(is_paragraph)]
assert not new_nodes
assert original_uids[::2] == uids
@@ -103,7 +103,7 @@ def test_deleted():
def test_deleted_end():
deleted_end = doctrees['deleted_end']
new_nodes = list(merge_doctrees(original, deleted_end, is_paragraph))
- uids = [n.uid for n in deleted_end.traverse(is_paragraph)]
+ uids = [n.uid for n in deleted_end.findall(is_paragraph)]
assert not new_nodes
assert original_uids[:-1] == uids
@@ -111,7 +111,7 @@ def test_deleted_end():
def test_insert():
insert = doctrees['insert']
new_nodes = list(merge_doctrees(original, insert, is_paragraph))
- uids = [n.uid for n in insert.traverse(is_paragraph)]
+ uids = [n.uid for n in insert.findall(is_paragraph)]
assert len(new_nodes) == 1
assert original_uids[0] == uids[0]
assert original_uids[1:] == uids[2:]
@@ -120,7 +120,7 @@ def test_insert():
def test_insert_beginning():
insert_beginning = doctrees['insert_beginning']
new_nodes = list(merge_doctrees(original, insert_beginning, is_paragraph))
- uids = [n.uid for n in insert_beginning.traverse(is_paragraph)]
+ uids = [n.uid for n in insert_beginning.findall(is_paragraph)]
assert len(new_nodes) == 1
assert len(uids) == 4
assert original_uids == uids[1:]
@@ -130,7 +130,7 @@ def test_insert_beginning():
def test_insert_similar():
insert_similar = doctrees['insert_similar']
new_nodes = list(merge_doctrees(original, insert_similar, is_paragraph))
- uids = [n.uid for n in insert_similar.traverse(is_paragraph)]
+ uids = [n.uid for n in insert_similar.findall(is_paragraph)]
assert len(new_nodes) == 1
assert new_nodes[0].rawsource == 'Anyway I need more'
assert original_uids[0] == uids[0]
diff --git a/tox.ini b/tox.ini
index 824ab3f38..f0afd779b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -32,9 +32,7 @@ commands=
[testenv:du-latest]
commands =
- git clone https://repo.or.cz/docutils.git {temp_dir}/docutils
- python -m pip install {temp_dir}/docutils/docutils
- rm -rf {temp_dir}/docutils
+ python -m pip install "git+https://repo.or.cz/docutils.git#subdirectory=docutils"
{[testenv]commands}
[testenv:flake8]