Skip to content

Commit 71cc5d8

Browse files
dependabot[bot]adamtheturtledanieleadesAA-Turnerdaniel.eades
authored
Bump types-docutils to 0.22.3.20251115 (#13634)
Co-authored-by: Adam Dangoor <[email protected]> Co-authored-by: danieleades <[email protected]> Co-authored-by: Adam Turner <[email protected]> Co-authored-by: daniel.eades <[email protected]>
1 parent a672c54 commit 71cc5d8

35 files changed

+187
-100
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ type-stubs = [
137137
# align with versions used elsewhere
138138
"types-colorama==0.4.15.20250801",
139139
"types-defusedxml==0.7.0.20250822",
140-
"types-docutils==0.21.0.20250525",
140+
"types-docutils==0.22.3.20251115",
141141
"types-Pillow==10.2.0.20240822",
142142
"types-Pygments==2.19.0.20251121",
143143
"types-requests==2.32.4.20250913",

sphinx/builders/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import TYPE_CHECKING, final
1111

1212
from docutils import nodes
13+
from docutils.utils import DependencyList
1314

1415
from sphinx._cli.util.colour import bold
1516
from sphinx.deprecation import _deprecation_warning
@@ -687,7 +688,7 @@ def write_doctree(
687688
doctree.settings = doctree.settings.copy()
688689
doctree.settings.warning_stream = None
689690
doctree.settings.env = None
690-
doctree.settings.record_dependencies = None
691+
doctree.settings.record_dependencies = DependencyList()
691692

692693
doctree_filename = self.doctreedir / f'{docname}.doctree'
693694
doctree_filename.parent.mkdir(parents=True, exist_ok=True)

sphinx/builders/_epub_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def fix_ids(self, tree: nodes.document) -> None:
294294
for target in tree.findall(nodes.target):
295295
self._update_node_id(target)
296296

297-
next_node: Node = target.next_node(ascend=True)
297+
next_node: Node | None = target.next_node(ascend=True)
298298
if isinstance(next_node, nodes.Element):
299299
self._update_node_id(next_node)
300300

sphinx/builders/latex/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def run(self, **kwargs: Any) -> None:
528528
citations += node
529529

530530
if len(citations) > 0:
531-
self.document += citations # type: ignore[attr-defined]
531+
self.document += citations
532532

533533

534534
class CitationReferenceTransform(SphinxPostTransform):

sphinx/builders/linkcheck.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from sphinx.util import logging, requests
3232
from sphinx.util._uri import encode_uri
3333
from sphinx.util.http_date import rfc1123_to_epoch
34-
from sphinx.util.nodes import get_node_line
34+
from sphinx.util.nodes import NodeMatcher, get_node_line
3535

3636
if TYPE_CHECKING:
3737
from collections.abc import Callable, Iterator, Sequence
@@ -221,7 +221,8 @@ class HyperlinkCollector(SphinxPostTransform):
221221
default_priority = 800
222222

223223
def run(self, **kwargs: Any) -> None:
224-
for node in self.document.findall():
224+
matcher = NodeMatcher(nodes.image, nodes.raw, nodes.reference)
225+
for node in matcher.findall(self.document):
225226
if uri := self.find_uri(node):
226227
self._add_uri(uri, node)
227228

sphinx/builders/xml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _translate(self, doctree: nodes.document) -> str:
8787

8888
# copied from docutils.writers.docutils_xml.Writer.translate()
8989
# so that we can override the translator class
90-
visitor: XMLTranslator = self.create_translator(doctree)
90+
visitor: XMLTranslator = self.create_translator(doctree) # type: ignore[assignment]
9191
doctree.walkabout(visitor)
9292
return ''.join(visitor.output)
9393

sphinx/directives/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,14 @@ def run(self) -> list[Node]:
325325
docutils.unregister_role('')
326326
return []
327327
role_name = self.arguments[0]
328+
# TODO: TYPING: Upstream docutils should widen roles.role() to accept
329+
# the RST language module shape (has a `roles` mapping);
330+
# current stub requires _LanguageModule from docutils.languages.
328331
role, messages = roles.role(
329-
role_name, self.state_machine.language, self.lineno, self.state.reporter
332+
role_name,
333+
self.state_machine.language, # type: ignore[arg-type]
334+
self.lineno,
335+
self.state.reporter,
330336
)
331337
if role:
332338
docutils.register_role('', role) # type: ignore[arg-type]

sphinx/directives/code.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ class CodeBlock(SphinxDirective):
119119
def run(self) -> list[Node]:
120120
document = self.state.document
121121
code = '\n'.join(self.content)
122-
location = self.state_machine.get_source_and_line(self.lineno)
122+
source, line = self.state_machine.get_source_and_line(self.lineno)
123+
location: tuple[str, int] | None = (
124+
(source, line) if source is not None and line is not None else None
125+
)
123126

124127
linespec = self.options.get('emphasize-lines')
125128
if linespec:
@@ -141,7 +144,6 @@ def run(self) -> list[Node]:
141144
hl_lines = None
142145

143146
if 'dedent' in self.options:
144-
location = self.state_machine.get_source_and_line(self.lineno)
145147
lines = code.splitlines(True)
146148
lines = dedent_lines(lines, self.options['dedent'], location=location)
147149
code = ''.join(lines)
@@ -454,7 +456,10 @@ def run(self) -> list[Node]:
454456
self.options['diff'] = path
455457

456458
try:
457-
location = self.state_machine.get_source_and_line(self.lineno)
459+
source, line = self.state_machine.get_source_and_line(self.lineno)
460+
location: tuple[str, int] | None = (
461+
(source, line) if source is not None and line is not None else None
462+
)
458463
rel_filename, filename = self.env.relfn2path(self.arguments[0])
459464
self.env.note_dependency(rel_filename)
460465

sphinx/directives/other.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ def _insert_input(include_lines: list[str], source: str) -> None:
405405

406406
# Only enable this patch if there are listeners for 'include-read'.
407407
if self.env.events.listeners.get('include-read'):
408-
# See https://github.com/python/mypy/issues/2427 for details on the mypy issue
409-
self.state_machine.insert_input = _insert_input
408+
self.state_machine.insert_input = _insert_input # type: ignore[assignment,method-assign]
410409

411410
if self.arguments[0].startswith('<') and self.arguments[0].endswith('>'):
412411
# docutils "standard" includes, do not do path processing

sphinx/directives/patches.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from sphinx.util.osutil import SEP, relpath
1919

2020
if TYPE_CHECKING:
21+
from collections.abc import Sequence
2122
from typing import ClassVar
2223

2324
from docutils.nodes import Node
@@ -29,12 +30,12 @@
2930
logger = logging.getLogger(__name__)
3031

3132

32-
class Figure(images.Figure): # type: ignore[misc]
33+
class Figure(images.Figure):
3334
"""The figure directive which applies `:name:` option to the figure node
3435
instead of the image node.
3536
"""
3637

37-
def run(self) -> list[Node]:
38+
def run(self) -> Sequence[Node]:
3839
name = self.options.pop('name', None)
3940
result = super().run()
4041
if len(result) == 2 or isinstance(result[0], nodes.system_message):
@@ -55,12 +56,12 @@ def run(self) -> list[Node]:
5556
return [figure_node]
5657

5758

58-
class CSVTable(tables.CSVTable): # type: ignore[misc]
59+
class CSVTable(tables.CSVTable):
5960
"""The csv-table directive which searches a CSV file from Sphinx project's source
6061
directory when an absolute path is given via :file: option.
6162
"""
6263

63-
def run(self) -> list[Node]:
64+
def run(self) -> Sequence[nodes.table | nodes.system_message]:
6465
if 'file' in self.options and self.options['file'].startswith((SEP, os.sep)):
6566
env = self.state.document.settings.env
6667
filename = Path(self.options['file'])

0 commit comments

Comments
 (0)