From 746e9568075195c2af13fdaafcedd1bbd1cb0abb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 15:01:27 +0000 Subject: [PATCH 01/17] Bump types-docutils from 0.21.0.20250525 to 0.21.0.20250604 Bumps [types-docutils](https://github.com/typeshed-internal/stub_uploader) from 0.21.0.20250525 to 0.21.0.20250604. - [Commits](https://github.com/typeshed-internal/stub_uploader/commits) --- updated-dependencies: - dependency-name: types-docutils dependency-version: 0.21.0.20250604 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 70962dd7adf..280e56c6bf1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,7 +97,7 @@ lint = [ "sphinx-lint>=0.9", "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250516", - "types-docutils==0.21.0.20250525", + "types-docutils==0.21.0.20250604", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250516", "types-requests==2.32.4.20250611", # align with requests @@ -166,7 +166,7 @@ type-stubs = [ # align with versions used elsewhere "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250516", - "types-docutils==0.21.0.20250525", + "types-docutils==0.21.0.20250604", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250516", "types-requests==2.32.4.20250611", From 043820aac473f398cb54bc765c69100801648fcf Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Jun 2025 07:02:46 +0100 Subject: [PATCH 02/17] Remove unused type: ignore comments --- sphinx/directives/patches.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 94184de502c..87f9f65465a 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -30,7 +30,7 @@ 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. """ @@ -56,7 +56,7 @@ 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. """ From f9e30eb313b22c35e2ebfe82ac1087a8f82a356d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Jun 2025 07:08:52 +0100 Subject: [PATCH 03/17] Set stub reporter in test to actual Reporter --- tests/test_util/test_util_docutils_sphinx_directive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_util/test_util_docutils_sphinx_directive.py b/tests/test_util/test_util_docutils_sphinx_directive.py index eb1e4aea16a..e91a4d2ae23 100644 --- a/tests/test_util/test_util_docutils_sphinx_directive.py +++ b/tests/test_util/test_util_docutils_sphinx_directive.py @@ -11,6 +11,7 @@ state_classes, ) from docutils.statemachine import StringList +from docutils.utils import Reporter from sphinx.util.docutils import SphinxDirective, new_document @@ -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='', report_level=0, halt_level=0) if input_lines is not None: sm.input_lines = input_lines state = RSTState(sm) From 5ecdcafe2ef826c60ac9eb9d674e5e041282e452 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Jun 2025 07:11:16 +0100 Subject: [PATCH 04/17] Ignore a method-assign mypy error --- sphinx/directives/other.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 8c66ed383b5..a7e3b63f520 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -406,7 +406,7 @@ 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 + self.state_machine.insert_input = _insert_input # type: ignore[method-assign] if self.arguments[0].startswith('<') and self.arguments[0].endswith('>'): # docutils "standard" includes, do not do path processing From ad377efc11aed92d5ccfe815560f5be330b25652 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Jun 2025 07:14:00 +0100 Subject: [PATCH 05/17] Change return type to reflect that we do not know a sequence specific type --- sphinx/directives/patches.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index 87f9f65465a..0a4a9146b8a 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -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 @@ -35,7 +36,7 @@ class Figure(images.Figure): 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): From 457755d994d3b5e02bf8063797bbe80fd61e60f5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Jul 2025 22:11:13 +0100 Subject: [PATCH 06/17] Bump types-docutils --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6ed91b230e6..fab189d3dec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ lint = [ "sphinx-lint>=0.9", "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250516", - "types-docutils==0.21.0.20250604", + "types-docutils== 0.21.0.20250722", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250516", "types-requests==2.32.4.20250611", # align with requests @@ -167,7 +167,7 @@ type-stubs = [ # align with versions used elsewhere "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250516", - "types-docutils==0.21.0.20250604", + "types-docutils== 0.21.0.20250722", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250516", "types-requests==2.32.4.20250611", From f1caa2fee2f72d605d681a0d8d26208c60881ebc Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Jul 2025 22:15:53 +0100 Subject: [PATCH 07/17] Remove unused type ignores --- sphinx/builders/latex/transforms.py | 2 +- sphinx/directives/other.py | 3 +-- sphinx/environment/collectors/title.py | 2 +- sphinx/environment/collectors/toctree.py | 2 +- sphinx/io.py | 4 ++-- sphinx/transforms/__init__.py | 4 ++-- sphinx/transforms/references.py | 2 +- sphinx/util/docutils.py | 2 +- sphinx/writers/html.py | 2 +- sphinx/writers/html5.py | 2 +- sphinx/writers/manpage.py | 2 +- sphinx/writers/xml.py | 4 ++-- tests/test_markup/test_markup.py | 2 +- 13 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sphinx/builders/latex/transforms.py b/sphinx/builders/latex/transforms.py index 759a084cd00..f1e09399e05 100644 --- a/sphinx/builders/latex/transforms.py +++ b/sphinx/builders/latex/transforms.py @@ -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): diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 0fbc5b54bda..8c96b143dd6 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -405,8 +405,7 @@ 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 # type: ignore[method-assign] + self.state_machine.insert_input = _insert_input if self.arguments[0].startswith('<') and self.arguments[0].endswith('>'): # docutils "standard" includes, do not do path processing diff --git a/sphinx/environment/collectors/title.py b/sphinx/environment/collectors/title.py index 50dfa2bdc54..59a77ef3e7e 100644 --- a/sphinx/environment/collectors/title.py +++ b/sphinx/environment/collectors/title.py @@ -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 diff --git a/sphinx/environment/collectors/toctree.py b/sphinx/environment/collectors/toctree.py index 5c3d5c97f8c..571d4d964a5 100644 --- a/sphinx/environment/collectors/toctree.py +++ b/sphinx/environment/collectors/toctree.py @@ -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 diff --git a/sphinx/io.py b/sphinx/io.py index 1df5ac454ce..e98ecdd08dd 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -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. @@ -92,7 +92,7 @@ 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) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index 760a5e6a67d..b49151f0928 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -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: @@ -372,7 +372,7 @@ def apply(self, **kwargs: Any) -> None: # override default settings with :confval:`smartquotes_action` self.smartquotes_action = self.config.smartquotes_action - super().apply() # type: ignore[no-untyped-call] + super().apply() def is_available(self) -> bool: builders = self.config.smartquotes_excludes.get('builders', []) diff --git a/sphinx/transforms/references.py b/sphinx/transforms/references.py index 17380777997..8655dbfa5f3 100644 --- a/sphinx/transforms/references.py +++ b/sphinx/transforms/references.py @@ -25,7 +25,7 @@ def apply(self, **kwargs: Any) -> None: # suppress INFO level messages for a while reporter.report_level = max(reporter.WARNING_LEVEL, reporter.report_level) - super().apply() # type: ignore[no-untyped-call] + super().apply() finally: reporter.report_level = report_level diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 2673a3fc77f..02a154b4f3e 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -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() diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 04f9af122a4..27c041863e6 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -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} diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py index 39d7ecea680..a4a87ad1d66 100644 --- a/sphinx/writers/html5.py +++ b/sphinx/writers/html5.py @@ -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 diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index 282cd0ed14c..e2e71c76415 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -25,7 +25,7 @@ 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 diff --git a/sphinx/writers/xml.py b/sphinx/writers/xml.py index e9877825de6..9564933ba40 100644 --- a/sphinx/writers/xml.py +++ b/sphinx/writers/xml.py @@ -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: @@ -34,7 +34,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.""" diff --git a/tests/test_markup/test_markup.py b/tests/test_markup/test_markup.py index f9da6038c7f..fb4df4c400b 100644 --- a/tests/test_markup/test_markup.py +++ b/tests/test_markup/test_markup.py @@ -62,7 +62,7 @@ def parse_(rst): document = new_document() parser = RstParser() parser.parse(rst, document) - SphinxSmartQuotes(document, startnode=None).apply() # type: ignore[no-untyped-call] + SphinxSmartQuotes(document, startnode=None).apply() for msg in list(document.findall(nodes.system_message)): if msg['level'] == 1: msg.replace_self([]) From 9cf7fab2ad27729aeaa3d8fd20cb3a9703326522 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Jul 2025 22:26:20 +0100 Subject: [PATCH 08/17] Change a type ignore type --- sphinx/util/docutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 02a154b4f3e..c88cc665126 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -911,4 +911,4 @@ def _get_settings( defaults=defaults, read_config_files=read_config_files, ) - return option_parser.get_default_values() + return option_parser.get_default_values() # type: ignore[no-untyped-call] From f7a013f9d55bd09d01685e403c605093004127c9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 26 Jul 2025 22:25:22 +0100 Subject: [PATCH 09/17] Type narrow document | None --- sphinx/ext/inheritance_diagram.py | 1 + sphinx/writers/html.py | 1 + sphinx/writers/manpage.py | 1 + sphinx/writers/xml.py | 2 ++ 4 files changed, 5 insertions(+) diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index 83a6d4b7b01..f44bbb860ab 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -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 diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 27c041863e6..cb273cbdbd3 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -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 ( diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index e2e71c76415..fd655d08ea6 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -31,6 +31,7 @@ def __init__(self, builder: Builder) -> None: 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) diff --git a/sphinx/writers/xml.py b/sphinx/writers/xml.py index 9564933ba40..bf5bd17a8a5 100644 --- a/sphinx/writers/xml.py +++ b/sphinx/writers/xml.py @@ -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 ) @@ -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: From 2f40734cce8e3cd3ca0dee30838d475111b3b5cc Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 27 Jul 2025 07:06:37 +0100 Subject: [PATCH 10/17] Bump types-docutils and use type narrowing to remove one mypy error --- pyproject.toml | 4 ++-- sphinx/io.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 191fd352a21..d1d2c45163d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ lint = [ "sphinx-lint>=0.9", "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250708", - "types-docutils== 0.21.0.20250722", + "types-docutils==0.21.0.20250727", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250715", "types-requests==2.32.4.20250611", # align with requests @@ -167,7 +167,7 @@ type-stubs = [ # align with versions used elsewhere "types-colorama==0.4.15.20240311", "types-defusedxml==0.7.0.20250708", - "types-docutils== 0.21.0.20250722", + "types-docutils==0.21.0.20250727", "types-Pillow==10.2.0.20240822", "types-Pygments==2.19.0.20250715", "types-requests==2.32.4.20250611", diff --git a/sphinx/io.py b/sphinx/io.py index e98ecdd08dd..b9d1ddb10b5 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -97,6 +97,7 @@ def read(self, source: Input, parser: Parser, settings: Values) -> nodes.documen 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: From 9b9f1baea5705fb3ba504f98c48e72ae9db94e8c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 27 Jul 2025 07:08:05 +0100 Subject: [PATCH 11/17] Use type narrowing to remove one error --- sphinx/io.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx/io.py b/sphinx/io.py index b9d1ddb10b5..5b11b9e4918 100644 --- a/sphinx/io.py +++ b/sphinx/io.py @@ -102,6 +102,7 @@ def read(self, source: Input, parser: Parser, settings: Values) -> nodes.documen 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 From c3bf2b5280a20b20c144ec6237198a5cce214629 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 27 Jul 2025 07:46:10 +0100 Subject: [PATCH 12/17] Fix one type error - match return type to parent class --- sphinx/transforms/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index b49151f0928..6139109f961 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -22,7 +22,7 @@ from sphinx.util.nodes import apply_source_workaround, is_smartquotable if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Generator from typing import Any, Literal, TypeAlias from docutils.nodes import Node, Text @@ -395,7 +395,10 @@ 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: list[Text], + ) -> 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: From 0f721d1177ee74d45ced7157debbf092de7cdaed Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 29 Jul 2025 14:04:57 +0100 Subject: [PATCH 13/17] Type narrow to avoid one error --- sphinx/transforms/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index 6139109f961..075079c1673 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -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 From 5ce4fbeebdde4996317c55e2d2fa6c7e18877683 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 29 Jul 2025 14:21:39 +0100 Subject: [PATCH 14/17] Fix badly formatted type --- sphinx/transforms/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index 075079c1673..521f17737d9 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -399,7 +399,11 @@ def is_available(self) -> bool: def get_tokens( self, txtnodes: list[Text], - ) -> Generator[[tuple[Literal['plain', 'literal'], str]], None, None]: + ) -> 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: From 6e2a366aeb1d027f73cf3fb276229a14ff6cc9d9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 29 Jul 2025 14:24:57 +0100 Subject: [PATCH 15/17] Match get_tokens with its parent --- sphinx/transforms/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index 521f17737d9..d0e1eaf67b4 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -22,7 +22,7 @@ from sphinx.util.nodes import apply_source_workaround, is_smartquotable if TYPE_CHECKING: - from collections.abc import Generator + from collections.abc import Generator, Iterable from typing import Any, Literal, TypeAlias from docutils.nodes import Node, Text @@ -398,7 +398,7 @@ def is_available(self) -> bool: def get_tokens( self, - txtnodes: list[Text], + txtnodes: Iterable[Node], ) -> Generator[ tuple[Literal['plain', 'literal'], str], None, From 5301106d84faa7bc414dde05ec22a7cf9e412459 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 3 Aug 2025 12:12:08 +0100 Subject: [PATCH 16/17] Fix unused import --- sphinx/transforms/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/transforms/__init__.py b/sphinx/transforms/__init__.py index d0e1eaf67b4..7cdef224fcb 100644 --- a/sphinx/transforms/__init__.py +++ b/sphinx/transforms/__init__.py @@ -25,7 +25,7 @@ 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 From 7ca0ee0eb267bc2475a64676d34dc7be3f563645 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 3 Aug 2025 12:13:57 +0100 Subject: [PATCH 17/17] Update CSVTable.run return type --- sphinx/directives/patches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/directives/patches.py b/sphinx/directives/patches.py index f62bb587b94..59757bf5f4d 100644 --- a/sphinx/directives/patches.py +++ b/sphinx/directives/patches.py @@ -62,7 +62,7 @@ class CSVTable(tables.CSVTable): 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'])