From 46cf04625084b399df1222e02bf301c7a0ac154c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 04:55:54 +0000 Subject: [PATCH 1/4] Bump types-docutils from 0.21.0.20240704 to 0.21.0.20240708 Bumps [types-docutils](https://github.com/python/typeshed) from 0.21.0.20240704 to 0.21.0.20240708. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-docutils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 94b1f2455cd..d73e6fd4488 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ lint = [ "ruff==0.5.0", "mypy==1.10.1", "sphinx-lint", - "types-docutils==0.21.0.20240704", + "types-docutils==0.21.0.20240708", "types-requests", "importlib_metadata", # for mypy (Python<=3.9) "tomli", # for mypy (Python<=3.10) From fff53e8b04ff1b86373bbc0a47b59df21547260c Mon Sep 17 00:00:00 2001 From: James Addison Date: Tue, 9 Jul 2024 19:59:43 +0100 Subject: [PATCH 2/4] Update MyPy for types-docutils 0.21.0.20240708 --- sphinx/ext/autodoc/directive.py | 2 +- sphinx/util/nodes.py | 2 +- sphinx/util/parsing.py | 2 +- sphinx/util/typing.py | 3 +-- tests/test_util/test_util_docutils_sphinx_directive.py | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index f39b00f1ab5..52888ff5020 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -16,7 +16,7 @@ from sphinx.config import Config from sphinx.environment import BuildEnvironment - from sphinx.util.typing import _RSTState as RSTState + from sphinx.util.typing import RSTState logger = logging.getLogger(__name__) diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 5f4169458c7..130ff18d1db 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -26,7 +26,7 @@ from sphinx.builders import Builder from sphinx.environment import BuildEnvironment from sphinx.util.tags import Tags - from sphinx.util.typing import _RSTState as RSTState + from sphinx.util.typing import RSTState logger = logging.getLogger(__name__) diff --git a/sphinx/util/parsing.py b/sphinx/util/parsing.py index 432d9f3810b..e3e59671776 100644 --- a/sphinx/util/parsing.py +++ b/sphinx/util/parsing.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from collections.abc import Iterator - from sphinx.util.typing import _RSTState as RSTState + from sphinx.util.typing import RSTState def nested_parse_to_nodes( diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index dfffff20295..1f8a8ecb8ee 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -26,12 +26,11 @@ from collections.abc import Mapping from typing import Final, Literal, Protocol - from docutils.parsers.rst.states import RSTState as _RSTStateGeneric + from docutils.parsers.rst.states import RSTState from typing_extensions import TypeAlias, TypeIs from sphinx.application import Sphinx - _RSTState: TypeAlias = _RSTStateGeneric[list[str]] _RestifyMode: TypeAlias = Literal[ 'fully-qualified-except-typing', 'smart', diff --git a/tests/test_util/test_util_docutils_sphinx_directive.py b/tests/test_util/test_util_docutils_sphinx_directive.py index 20c08191f35..8f5ab3f8e38 100644 --- a/tests/test_util/test_util_docutils_sphinx_directive.py +++ b/tests/test_util/test_util_docutils_sphinx_directive.py @@ -15,12 +15,12 @@ def make_directive(*, env: SimpleNamespace, input_lines: StringList | None = Non return directive -def make_directive_and_state(*, env: SimpleNamespace, input_lines: StringList | None = None) -> tuple[RSTState[list[str]], SphinxDirective]: +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() if input_lines is not None: sm.input_lines = input_lines - state: RSTState[list[str]] = RSTState(sm) + state = RSTState(sm) state.document = new_document('') state.document.settings.env = env state.document.settings.tab_width = 4 From 766c9706edeb4dd94fdf906f5e6d198d8049dcd7 Mon Sep 17 00:00:00 2001 From: James Addison Date: Tue, 9 Jul 2024 20:07:07 +0100 Subject: [PATCH 3/4] Cleanup: remove unused import. --- sphinx/util/typing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 1f8a8ecb8ee..f19e054b30a 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -26,7 +26,6 @@ from collections.abc import Mapping from typing import Final, Literal, Protocol - from docutils.parsers.rst.states import RSTState from typing_extensions import TypeAlias, TypeIs from sphinx.application import Sphinx From d61d25baf07bb47d07276680260917eba139028d Mon Sep 17 00:00:00 2001 From: James Addison Date: Tue, 9 Jul 2024 20:18:10 +0100 Subject: [PATCH 4/4] Type-hints: import RSTState directly from types-docutils stubs instead of (now-removed) ``sphinx.utils.typing``. Relates-to commit 766c9706edeb4dd94fdf906f5e6d198d8049dcd7. --- sphinx/ext/autodoc/directive.py | 2 +- sphinx/util/nodes.py | 3 +-- sphinx/util/parsing.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 52888ff5020..9b0bf66a02c 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -13,10 +13,10 @@ if TYPE_CHECKING: from docutils.nodes import Node + from docutils.parsers.rst.states import RSTState from sphinx.config import Config from sphinx.environment import BuildEnvironment - from sphinx.util.typing import RSTState logger = logging.getLogger(__name__) diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 130ff18d1db..9f3e827c827 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -20,13 +20,12 @@ from docutils.nodes import Element from docutils.parsers.rst import Directive - from docutils.parsers.rst.states import Inliner + from docutils.parsers.rst.states import Inliner, RSTState from docutils.statemachine import StringList from sphinx.builders import Builder from sphinx.environment import BuildEnvironment from sphinx.util.tags import Tags - from sphinx.util.typing import RSTState logger = logging.getLogger(__name__) diff --git a/sphinx/util/parsing.py b/sphinx/util/parsing.py index e3e59671776..a8f937f8fe1 100644 --- a/sphinx/util/parsing.py +++ b/sphinx/util/parsing.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from collections.abc import Iterator - from sphinx.util.typing import RSTState + from docutils.parsers.rst.states import RSTState def nested_parse_to_nodes(