Skip to content

Commit e63e2f3

Browse files
Update MyPy for types-docutils 0.21.0.20240704 (#12511)
Co-authored-by: Adam Turner <[email protected]>
1 parent b23ac4f commit e63e2f3

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

sphinx/ext/autodoc/directive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
if TYPE_CHECKING:
1515
from docutils.nodes import Node
16-
from docutils.parsers.rst.states import RSTState
1716

1817
from sphinx.config import Config
1918
from sphinx.environment import BuildEnvironment
19+
from sphinx.util.typing import _RSTState as RSTState
2020

2121
logger = logging.getLogger(__name__)
2222

@@ -112,7 +112,7 @@ def run(self) -> list[Node]:
112112
reporter = self.state.document.reporter
113113

114114
try:
115-
source, lineno = reporter.get_source_and_line(
115+
source, lineno = reporter.get_source_and_line( # type: ignore[attr-defined]
116116
self.lineno)
117117
except AttributeError:
118118
source, lineno = (None, None)

sphinx/ext/inheritance_diagram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,15 @@ def run(self) -> list[Node]:
378378
aliases=self.config.inheritance_alias,
379379
top_classes=node['top-classes'])
380380
except InheritanceException as err:
381-
return [node.document.reporter.warning(err, line=self.lineno)] # type: ignore[union-attr]
381+
return [node.document.reporter.warning(err, line=self.lineno)]
382382

383383
# Create xref nodes for each target of the graph's image map and
384384
# add them to the doc tree so that Sphinx can resolve the
385385
# references to real URLs later. These nodes will eventually be
386386
# removed from the doctree after we're done with them.
387387
for name in graph.get_all_class_names():
388388
refnodes, x = class_role( # type: ignore[call-arg,misc]
389-
'class', ':class:`%s`' % name, name, 0, self.state)
389+
'class', ':class:`%s`' % name, name, 0, self.state.inliner)
390390
node.extend(refnodes)
391391
# Store the graph object so we can use it to generate the
392392
# dot file later

sphinx/util/nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020

2121
from docutils.nodes import Element
2222
from docutils.parsers.rst import Directive
23-
from docutils.parsers.rst.states import Inliner, RSTState
23+
from docutils.parsers.rst.states import Inliner
2424
from docutils.statemachine import StringList
2525

2626
from sphinx.builders import Builder
2727
from sphinx.environment import BuildEnvironment
2828
from sphinx.util.tags import Tags
29+
from sphinx.util.typing import _RSTState as RSTState
2930

3031
logger = logging.getLogger(__name__)
3132

sphinx/util/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
if TYPE_CHECKING:
1212
from collections.abc import Iterator
1313

14-
from docutils.parsers.rst.states import RSTState
14+
from sphinx.util.typing import _RSTState as RSTState
1515

1616

1717
def nested_parse_to_nodes(

sphinx/util/typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
from collections.abc import Mapping
2727
from typing import Final, Literal
2828

29+
from docutils.parsers.rst.states import RSTState as _RSTStateGeneric
2930
from typing_extensions import TypeAlias, TypeIs
3031

3132
from sphinx.application import Sphinx
3233

34+
_RSTState: TypeAlias = _RSTStateGeneric[list[str]]
3335
_RestifyMode: TypeAlias = Literal[
3436
'fully-qualified-except-typing',
3537
'smart',

tests/test_util/test_util_docutils_sphinx_directive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111

1212

1313
def make_directive(*, env: SimpleNamespace, input_lines: StringList | None = None) -> SphinxDirective:
14-
state, directive = make_directive_and_state(env=env, input_lines=input_lines)
14+
_, directive = make_directive_and_state(env=env, input_lines=input_lines)
1515
return directive
1616

1717

18-
def make_directive_and_state(*, env: SimpleNamespace, input_lines: StringList | None = None) -> tuple[RSTState, SphinxDirective]:
18+
def make_directive_and_state(*, env: SimpleNamespace, input_lines: StringList | None = None) -> tuple[RSTState[list[str]], SphinxDirective]:
1919
sm = RSTStateMachine(state_classes, initial_state='Body')
2020
sm.reporter = object()
2121
if input_lines is not None:
2222
sm.input_lines = input_lines
23-
state = RSTState(sm)
23+
state: RSTState[list[str]] = RSTState(sm)
2424
state.document = new_document('<tests>')
2525
state.document.settings.env = env
2626
state.document.settings.tab_width = 4

0 commit comments

Comments
 (0)