mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
commit
6e8ff897f7
@ -39,7 +39,7 @@ if False:
|
|||||||
from sphinx.config import Config # NOQA
|
from sphinx.config import Config # NOQA
|
||||||
from sphinx.environment import BuildEnvironment # NOQA
|
from sphinx.environment import BuildEnvironment # NOQA
|
||||||
from sphinx.util.docfields import Field # 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
|
# RE to strip backslash escapes
|
||||||
@ -60,7 +60,7 @@ class ObjectDescription(SphinxDirective):
|
|||||||
final_argument_whitespace = True
|
final_argument_whitespace = True
|
||||||
option_spec = {
|
option_spec = {
|
||||||
'noindex': directives.flag,
|
'noindex': directives.flag,
|
||||||
}
|
} # type: Dict[str, DirectiveOption]
|
||||||
|
|
||||||
# types of doc fields that this directive handles, see sphinx.util.docfields
|
# types of doc fields that this directive handles, see sphinx.util.docfields
|
||||||
doc_field_types = [] # type: List[Field]
|
doc_field_types = [] # type: List[Field]
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
:license: BSD, see LICENSE for details.
|
: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 import nodes
|
||||||
from docutils.parsers.rst.states import Inliner
|
from docutils.parsers.rst.states import Inliner
|
||||||
@ -26,6 +26,8 @@ else:
|
|||||||
|
|
||||||
N_co = TypeVar('N_co', bound=nodes.Node, covariant=True)
|
N_co = TypeVar('N_co', bound=nodes.Node, covariant=True)
|
||||||
|
|
||||||
|
# An entry of Directive.option_spec
|
||||||
|
DirectiveOption = Callable[[str], Any]
|
||||||
|
|
||||||
# common role functions
|
# common role functions
|
||||||
RoleFunction = Callable[[text_type, text_type, text_type, int, Inliner, Dict, List[text_type]],
|
RoleFunction = Callable[[text_type, text_type, text_type, int, Inliner, Dict, List[text_type]],
|
||||||
|
Loading…
Reference in New Issue
Block a user