Skip to content

Bump types-docutils from 0.21.0.20250525 to 0.21.0.20250604 #13634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
746e956
Bump types-docutils from 0.21.0.20250525 to 0.21.0.20250604
dependabot[bot] Jun 11, 2025
043820a
Remove unused type: ignore comments
adamtheturtle Jun 24, 2025
f9e30eb
Set stub reporter in test to actual Reporter
adamtheturtle Jun 24, 2025
5ecdcaf
Ignore a method-assign mypy error
adamtheturtle Jun 24, 2025
ad377ef
Change return type to reflect that we do not know a sequence specific…
adamtheturtle Jun 24, 2025
8f0b4e7
Merge branch 'master' into dependabot/pip/types-docutils-0.21.0.20250604
adamtheturtle Jun 24, 2025
3fb0b63
Merge branch 'master' into dependabot/pip/types-docutils-0.21.0.20250604
AA-Turner Jul 23, 2025
457755d
Bump types-docutils
adamtheturtle Jul 23, 2025
f1caa2f
Remove unused type ignores
adamtheturtle Jul 23, 2025
9cf7fab
Change a type ignore type
adamtheturtle Jul 23, 2025
f3ea8a4
Merge branch 'master' into dependabot/pip/types-docutils-0.21.0.20250604
adamtheturtle Jul 24, 2025
f7a013f
Type narrow document | None
adamtheturtle Jul 26, 2025
2f40734
Bump types-docutils and use type narrowing to remove one mypy error
adamtheturtle Jul 27, 2025
9b9f1ba
Use type narrowing to remove one error
adamtheturtle Jul 27, 2025
c3bf2b5
Fix one type error - match return type to parent class
adamtheturtle Jul 27, 2025
39a5985
Merge remote-tracking branch 'upstream/master' into dependabot/pip/ty…
adamtheturtle Jul 29, 2025
0f721d1
Type narrow to avoid one error
adamtheturtle Jul 29, 2025
5ce4fbe
Fix badly formatted type
adamtheturtle Jul 29, 2025
6e2a366
Match get_tokens with its parent
adamtheturtle Jul 29, 2025
7ba8bb5
Merge remote-tracking branch 'upstream/master' into dependabot/pip/ty…
adamtheturtle Aug 3, 2025
5301106
Fix unused import
adamtheturtle Aug 3, 2025
7ca0ee0
Update CSVTable.run return type
adamtheturtle Aug 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,35 @@ dependencies = [
]
dynamic = ["version"]

[project.optional-dependencies]
docs = [
"sphinxcontrib-websupport",
]
lint = [
"ruff==0.12.7",
"mypy==1.17.0",
"sphinx-lint>=0.9",
"types-colorama==0.4.15.20240311",
"types-defusedxml==0.7.0.20250708",
"types-docutils==0.21.0.20250728",
"types-Pillow==10.2.0.20240822",
"types-Pygments==2.19.0.20250715",
"types-requests==2.32.4.20250611", # align with requests
"types-urllib3==1.26.25.14",
"pyright==1.1.400",
"pytest>=8.0",
"pypi-attestations==0.0.27",
"betterproto==2.0.0b6",
]
test = [
"pytest>=8.0",
"pytest-xdist[psutil]>=3.4",
"defusedxml>=0.7.1", # for secure XML/HTML parsing
"cython>=3.0",
"setuptools>=70.0", # for Cython compilation
"typing_extensions>=4.9", # for typing_extensions.Unpack
]

[[project.authors]]
name = "Adam Turner"
email = "aa-turner@users.noreply.github.com"
Expand Down Expand Up @@ -129,16 +158,16 @@ translations = [
"Jinja2>=3.1",
]
types = [
"mypy==1.17.1",
"mypy==1.17.0",
"pyrefly",
"pyright==1.1.400",
{ include-group = "type-stubs" },
]
type-stubs = [
# align with versions used elsewhere
"types-colorama==0.4.15.20250801",
"types-colorama==0.4.15.20240311",
"types-defusedxml==0.7.0.20250708",
"types-docutils==0.21.0.20250525",
"types-docutils==0.21.0.20250728",
"types-Pillow==10.2.0.20240822",
"types-Pygments==2.19.0.20250715",
"types-requests==2.32.4.20250611",
Expand Down Expand Up @@ -218,6 +247,7 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = [
# tests/
"tests.test_project",
"tests.test_versioning",
# tests/test_builders
"tests.test_builders.test_build",
Expand All @@ -227,6 +257,8 @@ module = [
# tests/test_directives
"tests.test_directives.test_directive_code",
"tests.test_directives.test_directives_no_typesetting",
# tests/test_environment
"tests.test_environment.test_environment",
# tests/test_extensions
"tests.test_extensions.test_ext_autodoc_autoclass",
"tests.test_extensions.test_ext_autosummary_imports",
Expand All @@ -235,6 +267,7 @@ module = [
"tests.test_extensions.test_ext_napoleon",
# tests/test_markup
"tests.test_markup.test_markup",
"tests.test_markup.test_parser",
# tests/test_theming
"tests.test_theming.test_templating",
"tests.test_theming.test_theming",
Expand Down Expand Up @@ -293,6 +326,7 @@ check_untyped_defs = false
disable_error_code = [
"annotation-unchecked",
]
disallow_incomplete_defs = false
disallow_untyped_calls = false
disallow_untyped_defs = false

Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/latex/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def run(self, **kwargs: Any) -> None:
citations += node

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


class CitationReferenceTransform(SphinxPostTransform):
Expand Down
1 change: 0 additions & 1 deletion sphinx/directives/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ def _insert_input(include_lines: list[str], source: str) -> None:

# Only enable this patch if there are listeners for 'include-read'.
if self.env.events.listeners.get('include-read'):
# See https://github.com/python/mypy/issues/2427 for details on the mypy issue
self.state_machine.insert_input = _insert_input

if self.arguments[0].startswith('<') and self.arguments[0].endswith('>'):
Expand Down
9 changes: 5 additions & 4 deletions sphinx/directives/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from sphinx.util.osutil import SEP, relpath

if TYPE_CHECKING:
from collections.abc import Sequence
from typing import ClassVar

from docutils.nodes import Node
Expand All @@ -30,12 +31,12 @@
logger = logging.getLogger(__name__)


class Figure(images.Figure): # type: ignore[misc]
class Figure(images.Figure):
"""The figure directive which applies `:name:` option to the figure node
instead of the image node.
"""

def run(self) -> list[Node]:
def run(self) -> Sequence[Node]:
name = self.options.pop('name', None)
result = super().run()
if len(result) == 2 or isinstance(result[0], nodes.system_message):
Expand All @@ -56,12 +57,12 @@ def run(self) -> list[Node]:
return [figure_node]


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

def run(self) -> list[Node]:
def run(self) -> list[nodes.table | nodes.system_message]:
if 'file' in self.options and self.options['file'].startswith((SEP, os.sep)):
env = self.state.document.settings.env
filename = Path(self.options['file'])
Expand Down
2 changes: 1 addition & 1 deletion sphinx/environment/collectors/title.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
for node in doctree.findall(nodes.section):
visitor = SphinxContentsFilter(doctree)
node[0].walkabout(visitor)
titlenode += visitor.get_entry_text() # type: ignore[no-untyped-call]
titlenode += visitor.get_entry_text()
break
else:
# document has no title
Expand Down
2 changes: 1 addition & 1 deletion sphinx/environment/collectors/toctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def build_toc(
# and unnecessary stuff
visitor = SphinxContentsFilter(doctree)
title.walkabout(visitor)
nodetext = visitor.get_entry_text() # type: ignore[no-untyped-call]
nodetext = visitor.get_entry_text()
anchorname = _make_anchor_name(sectionnode['ids'], numentries)
# make these nodes:
# list_item -> compact_paragraph -> reference
Expand Down
1 change: 1 addition & 0 deletions sphinx/ext/inheritance_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ def run(self) -> list[Node]:
include_subclasses='include-subclasses' in self.options,
)
except InheritanceException as err:
assert node.document is not None
return [node.document.reporter.warning(err, line=self.lineno)]

# Create xref nodes for each target of the graph's image map and
Expand Down
6 changes: 4 additions & 2 deletions sphinx/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
warnings.warn('sphinx.io is deprecated', RemovedInSphinx10Warning, stacklevel=2)


class SphinxBaseReader(standalone.Reader): # type: ignore[misc]
class SphinxBaseReader(standalone.Reader):
"""A base class of readers for Sphinx.

This replaces reporter by Sphinx's on generating document.
Expand Down Expand Up @@ -92,15 +92,17 @@ def _setup_transforms(self, transforms: list[type[Transform]], /) -> None:

def read(self, source: Input, parser: Parser, settings: Values) -> nodes.document: # type: ignore[type-arg]
self.source = source
if not self.parser: # type: ignore[has-type]
if not self.parser:
self.parser = parser
self.settings = settings
self.input = self.read_source(settings.env)
self.parse()
assert self.document is not None
return self.document

def read_source(self, env: BuildEnvironment) -> str:
"""Read content from source and do post-process."""
assert self.source is not None
content = self.source.read()

# emit "source-read" event
Expand Down
16 changes: 12 additions & 4 deletions sphinx/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from sphinx.util.nodes import apply_source_workaround, is_smartquotable

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Generator, Iterable
from typing import Any, Literal, TypeAlias

from docutils.nodes import Node, Text
from docutils.nodes import Node
from typing_extensions import TypeIs

from sphinx.application import Sphinx
Expand Down Expand Up @@ -92,7 +92,7 @@ def apply_transforms(self) -> None:
if not hasattr(self.document.settings, 'env') and self.env:
self.document.settings.env = self.env

super().apply_transforms() # type: ignore[misc]
super().apply_transforms()
else:
# wrap the target node by document node during transforming
try:
Expand Down Expand Up @@ -281,6 +281,7 @@ def is_translatable_node(node: Node) -> TypeIs[nodes.Element]:
return isinstance(node, target_nodes)

for node in self.document.findall(is_translatable_node):
assert isinstance(node, nodes.Element)
node['translatable'] = True


Expand Down Expand Up @@ -395,7 +396,14 @@ def is_available(self) -> bool:
language = self.env.settings['language_code']
return any(tag in smartchars.quotes for tag in normalize_language_tag(language))

def get_tokens(self, txtnodes: list[Text]) -> Iterator[tuple[str, str]]:
def get_tokens(
self,
txtnodes: Iterable[Node],
) -> Generator[
tuple[Literal['plain', 'literal'], str],
None,
None,
]:
# A generator that yields ``(texttype, nodetext)`` tuples for a list
# of "Text" nodes (interface to ``smartquotes.educate_tokens()``).
for txtnode in txtnodes:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/util/docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,4 +911,4 @@ def _get_settings(
defaults=defaults,
read_config_files=read_config_files,
)
return option_parser.get_default_values() # type: ignore[return-value]
return option_parser.get_default_values() # type: ignore[no-untyped-call]
3 changes: 2 additions & 1 deletion sphinx/writers/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# https://www.arnebrodowski.de/blog/write-your-own-restructuredtext-writer.html


class HTMLWriter(html4css1.Writer): # type: ignore[misc]
class HTMLWriter(html4css1.Writer):
# override embed-stylesheet default value to False.
settings_default_overrides = {'embed_stylesheet': False}

Expand All @@ -33,6 +33,7 @@ def translate(self) -> None:
# sadly, this is mostly copied from parent class
visitor = self.builder.create_translator(self.document, self.builder)
self.visitor = cast('HTML5Translator', visitor)
assert self.document is not None
self.document.walkabout(visitor)
self.output = self.visitor.astext()
for attr in (
Expand Down
2 changes: 1 addition & 1 deletion sphinx/writers/html5.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def multiply_length(length: str, scale: int) -> str:
return f'{int(result)}{unit}'


class HTML5Translator(SphinxTranslator, BaseTranslator): # type: ignore[misc]
class HTML5Translator(SphinxTranslator, BaseTranslator):
"""Our custom HTML translator."""

builder: StandaloneHTMLBuilder
Expand Down
3 changes: 2 additions & 1 deletion sphinx/writers/manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
logger = logging.getLogger(__name__)


class ManualPageWriter(manpage.Writer): # type: ignore[misc]
class ManualPageWriter(manpage.Writer):
def __init__(self, builder: Builder) -> None:
super().__init__()
self.builder = builder

def translate(self) -> None:
assert self.document is not None
transform = NestedInlineTransform(self.document)
transform.apply()
visitor = self.builder.create_translator(self.document, self.builder)
Expand Down
6 changes: 4 additions & 2 deletions sphinx/writers/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sphinx.builders import Builder


class XMLWriter(docutils_xml.Writer): # type: ignore[misc]
class XMLWriter(docutils_xml.Writer):
output: str

def __init__(self, builder: Builder) -> None:
Expand All @@ -21,6 +21,7 @@ def __init__(self, builder: Builder) -> None:
self._config = builder.config

def translate(self, *args: Any, **kwargs: Any) -> None:
assert self.document is not None
self.document.settings.newlines = self.document.settings.indents = (
self._config.xml_pretty
)
Expand All @@ -34,7 +35,7 @@ def translate(self, *args: Any, **kwargs: Any) -> None:
self.output = ''.join(visitor.output) # type: ignore[attr-defined]


class PseudoXMLWriter(docutils_xml.Writer): # type: ignore[misc]
class PseudoXMLWriter(docutils_xml.Writer):
supported = ('pprint', 'pformat', 'pseudoxml')
"""Formats this writer supports."""

Expand All @@ -49,6 +50,7 @@ def __init__(self, builder: Builder) -> None:
self.builder = builder

def translate(self) -> None:
assert self.document is not None
self.output = self.document.pformat()

def supports(self, format: str) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_util/test_util_docutils_sphinx_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
state_classes,
)
from docutils.statemachine import StringList
from docutils.utils import Reporter

from sphinx.util.docutils import SphinxDirective, new_document

Expand All @@ -26,7 +27,7 @@ def make_directive_and_state(
*, env: SimpleNamespace, input_lines: StringList | None = None
) -> tuple[RSTState, SphinxDirective]:
sm = RSTStateMachine(state_classes, initial_state='Body')
sm.reporter = object()
sm.reporter = Reporter(source='<tests>', report_level=0, halt_level=0)
if input_lines is not None:
sm.input_lines = input_lines
state = RSTState(sm)
Expand Down
Loading