mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix type annotations for 'env-merge-info' callbacks
This commit is contained in:
@@ -543,7 +543,7 @@ class Sphinx:
|
||||
self,
|
||||
event: Literal['env-merge-info'],
|
||||
callback: Callable[
|
||||
[Sphinx, BuildEnvironment, list[str], BuildEnvironment], None
|
||||
[Sphinx, BuildEnvironment, Set[str], BuildEnvironment], None
|
||||
],
|
||||
priority: int = 500
|
||||
) -> int:
|
||||
|
||||
@@ -5,6 +5,8 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
@@ -55,7 +57,7 @@ class EnvironmentCollector:
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
"""Merge in specified data regarding docnames from a different `BuildEnvironment`
|
||||
|
||||
@@ -19,6 +19,8 @@ from sphinx.util.images import guess_mimetype
|
||||
from sphinx.util.osutil import _relative_path
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
from docutils.nodes import Node
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
@@ -38,7 +40,7 @@ class ImageCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
env.images.merge_other(docnames, other.images)
|
||||
@@ -142,7 +144,7 @@ class DownloadFileCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
env.dlfiles.merge_other(docnames, other.dlfiles)
|
||||
|
||||
@@ -9,6 +9,8 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
from sphinx.util.osutil import _relative_path, fs_encoding
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
from docutils import nodes
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
@@ -26,7 +28,7 @@ class DependenciesCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
for docname in docnames:
|
||||
|
||||
@@ -9,6 +9,8 @@ from docutils import nodes
|
||||
from sphinx.environment.collectors import EnvironmentCollector
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.util.typing import ExtensionMetadata
|
||||
@@ -24,7 +26,7 @@ class MetadataCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
for docname in docnames:
|
||||
|
||||
@@ -10,6 +10,8 @@ from sphinx.environment.collectors import EnvironmentCollector
|
||||
from sphinx.transforms import SphinxContentsFilter
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.environment import BuildEnvironment
|
||||
from sphinx.util.typing import ExtensionMetadata
|
||||
@@ -26,7 +28,7 @@ class TitleCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
for docname in docnames:
|
||||
|
||||
@@ -15,7 +15,7 @@ from sphinx.transforms import SphinxContentsFilter
|
||||
from sphinx.util import logging, url_re
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Sequence, Set
|
||||
|
||||
from docutils.nodes import Element, Node
|
||||
|
||||
@@ -47,7 +47,7 @@ class TocTreeCollector(EnvironmentCollector):
|
||||
self,
|
||||
app: Sphinx,
|
||||
env: BuildEnvironment,
|
||||
docnames: set[str],
|
||||
docnames: Set[str],
|
||||
other: BuildEnvironment,
|
||||
) -> None:
|
||||
for docname in docnames:
|
||||
|
||||
@@ -150,7 +150,7 @@ class EventManager:
|
||||
self,
|
||||
name: Literal['env-merge-info'],
|
||||
callback: Callable[
|
||||
[Sphinx, BuildEnvironment, list[str], BuildEnvironment], None
|
||||
[Sphinx, BuildEnvironment, Set[str], BuildEnvironment], None
|
||||
],
|
||||
priority: int,
|
||||
) -> int: ...
|
||||
|
||||
@@ -2,7 +2,10 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import os.path
|
||||
from typing import Any
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Set
|
||||
|
||||
|
||||
class FilenameUniqDict(dict[str, tuple[set[str], str]]):
|
||||
@@ -37,7 +40,7 @@ class FilenameUniqDict(dict[str, tuple[set[str], str]]):
|
||||
self._existing.discard(unique)
|
||||
|
||||
def merge_other(
|
||||
self, docnames: set[str], other: dict[str, tuple[set[str], Any]]
|
||||
self, docnames: Set[str], other: dict[str, tuple[set[str], Any]]
|
||||
) -> None:
|
||||
for filename, (docs, _unique) in other.items():
|
||||
for doc in docs & set(docnames):
|
||||
@@ -73,7 +76,7 @@ class DownloadFiles(dict[str, tuple[set[str], str]]):
|
||||
del self[filename]
|
||||
|
||||
def merge_other(
|
||||
self, docnames: set[str], other: dict[str, tuple[set[str], Any]]
|
||||
self, docnames: Set[str], other: dict[str, tuple[set[str], Any]]
|
||||
) -> None:
|
||||
for filename, (docs, _dest) in other.items():
|
||||
for docname in docs & set(docnames):
|
||||
|
||||
Reference in New Issue
Block a user