diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index f9d7497f9..f42e2cdf9 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -39,7 +39,7 @@ if False: from sphinx.config import Config # NOQA from sphinx.environment import BuildEnvironment # NOQA from sphinx.util.docfields import Field # NOQA - from sphinx.util.typing import unicode # NOQA + from sphinx.util.typing import DirectiveOption, unicode # NOQA # RE to strip backslash escapes @@ -60,7 +60,7 @@ class ObjectDescription(SphinxDirective): final_argument_whitespace = True option_spec = { 'noindex': directives.flag, - } + } # type: Dict[str, DirectiveOption] # types of doc fields that this directive handles, see sphinx.util.docfields doc_field_types = [] # type: List[Field] diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index e0cf0104b..d31b6044a 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -9,7 +9,7 @@ :license: BSD, see LICENSE for details. """ -from typing import Callable, Dict, List, Tuple, TypeVar +from typing import Any, Callable, Dict, List, Tuple, TypeVar from docutils import nodes from docutils.parsers.rst.states import Inliner @@ -26,6 +26,8 @@ else: N_co = TypeVar('N_co', bound=nodes.Node, covariant=True) +# An entry of Directive.option_spec +DirectiveOption = Callable[[str], Any] # common role functions RoleFunction = Callable[[text_type, text_type, text_type, int, Inliner, Dict, List[text_type]],