Merge pull request #5730 from tk0miya/fix_typehints_for_DirectiveOption

Add DirectiveOption type to an entry of Directive.option_spec
This commit is contained in:
Takeshi KOMIYA 2018-12-08 01:06:22 +09:00 committed by GitHub
commit 6e8ff897f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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]

View File

@ -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]],