diff options
-rw-r--r-- | sphinx/application.py | 6 | ||||
-rw-r--r-- | sphinx/domains/__init__.py | 2 | ||||
-rw-r--r-- | sphinx/registry.py | 4 | ||||
-rw-r--r-- | sphinx/util/docutils.py | 8 |
4 files changed, 10 insertions, 10 deletions
diff --git a/sphinx/application.py b/sphinx/application.py index bec79b7ff..c60f12e96 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -523,7 +523,7 @@ class Sphinx: self.registry.add_translator(name, translator_class, override=override) def add_node(self, node, override=False, **kwds): - # type: (nodes.Node, bool, Any) -> None + # type: (Type[nodes.Node], bool, Any) -> None """Register a Docutils node class. This is necessary for Docutils internals. It may also be used in the @@ -562,7 +562,7 @@ class Sphinx: self.registry.add_translation_handlers(node, **kwds) def add_enumerable_node(self, node, figtype, title_getter=None, override=False, **kwds): - # type: (nodes.Node, unicode, TitleGetter, bool, Any) -> None + # type: (Type[nodes.Element], unicode, TitleGetter, bool, Any) -> None """Register a Docutils node class as a numfig target. Sphinx numbers the node automatically. And then the users can refer it @@ -591,7 +591,7 @@ class Sphinx: @property def enumerable_nodes(self): - # type: () -> Dict[nodes.Node, Tuple[unicode, TitleGetter]] + # type: () -> Dict[Type[nodes.Element], Tuple[unicode, TitleGetter]] warnings.warn('app.enumerable_nodes() is deprecated. ' 'Use app.get_domain("std").enumerable_nodes instead.', RemovedInSphinx30Warning, stacklevel=2) diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py index a221c783d..01d6a9d2d 100644 --- a/sphinx/domains/__init__.py +++ b/sphinx/domains/__init__.py @@ -159,7 +159,7 @@ class Domain: #: role name -> a warning message if reference is missing dangling_warnings = {} # type: Dict[unicode, unicode] #: node_class -> (enum_node_type, title_getter) - enumerable_nodes = {} # type: Dict[Type[nodes.Node], Tuple[unicode, Callable]] + enumerable_nodes = {} # type: Dict[Type[nodes.Element], Tuple[unicode, Callable]] #: data value for a fresh environment initial_data = {} # type: Dict diff --git a/sphinx/registry.py b/sphinx/registry.py index 03bdb885e..1ffece84c 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -90,7 +90,7 @@ class SphinxComponentRegistry: #: additional enumerable nodes #: a dict of node class -> tuple of figtype and title_getter function - self.enumerable_nodes = {} # type: Dict[nodes.Node, Tuple[unicode, TitleGetter]] + self.enumerable_nodes = {} # type: Dict[Type[nodes.Element], Tuple[unicode, TitleGetter]] # NOQA #: HTML inline and block math renderers #: a dict of name -> tuple of visit function and depart function @@ -438,7 +438,7 @@ class SphinxComponentRegistry: self.latex_packages.append((name, options)) def add_enumerable_node(self, node, figtype, title_getter=None, override=False): - # type: (nodes.Node, unicode, TitleGetter, bool) -> None + # type: (Type[nodes.Element], unicode, TitleGetter, bool) -> None logger.debug('[app] adding enumerable node: (%r, %r, %r)', node, figtype, title_getter) if node in self.enumerable_nodes and not override: raise ExtensionError(__('enumerable_node %r already registered') % node) diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 334465213..8d94ccebc 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -36,7 +36,7 @@ report_re = re.compile('^(.+?:(?:\\d+)?): \\((DEBUG|INFO|WARNING|ERROR|SEVERE)/( if False: # For type annotation - from typing import Any, Callable, Generator, List, Set, Tuple # NOQA + from typing import Any, Callable, Generator, List, Set, Tuple, Type # NOQA from docutils.statemachine import State, ViewList # NOQA from sphinx.config import Config # NOQA from sphinx.environment import BuildEnvironment # NOQA @@ -66,13 +66,13 @@ def docutils_namespace(): def is_node_registered(node): - # type: (nodes.Node) -> bool + # type: (Type[nodes.Element]) -> bool """Check the *node* is already registered.""" return hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__) def register_node(node): - # type: (nodes.Node) -> None + # type: (Type[nodes.Element]) -> None """Register a node to docutils. This modifies global state of some visitors. So it is better to use this @@ -84,7 +84,7 @@ def register_node(node): def unregister_node(node): - # type: (nodes.Node) -> None + # type: (Type[nodes.Element]) -> None """Unregister a node from docutils. This is inverse of ``nodes._add_nodes_class_names()``. |