Update type annotations

This commit is contained in:
Takeshi KOMIYA 2017-01-09 18:14:53 +09:00
parent d4271c0dce
commit ecd7b62148
8 changed files with 10 additions and 10 deletions

View File

@ -564,7 +564,7 @@ class Sphinx(object):
def emit(self, event, *args): def emit(self, event, *args):
# type: (unicode, Any) -> List # type: (unicode, Any) -> List
try: try:
logger.debug2('[app] emitting event: %r%s', event, repr(args)[:100]) logger.debug('[app] emitting event: %r%s', event, repr(args)[:100])
except Exception: except Exception:
# not every object likes to be repr()'d (think # not every object likes to be repr()'d (think
# random stuff coming via autodoc) # random stuff coming via autodoc)

View File

@ -391,7 +391,7 @@ class Builder(object):
self.write_doc(docname, doctree) self.write_doc(docname, doctree)
def _write_parallel(self, docnames, nproc): def _write_parallel(self, docnames, nproc):
# type: (Iterable[unicode], int) -> None # type: (Sequence[unicode], int) -> None
def write_process(docs): def write_process(docs):
# type: (List[Tuple[unicode, nodes.Node]]) -> None # type: (List[Tuple[unicode, nodes.Node]]) -> None
for docname, doctree in docs: for docname, doctree in docs:

View File

@ -732,7 +732,7 @@ class StandaloneHTMLBuilder(Builder):
reference.append(node) reference.append(node)
def load_indexer(self, docnames): def load_indexer(self, docnames):
# type: (Set[unicode]) -> None # type: (Iterable[unicode]) -> None
keep = set(self.env.all_docs) - set(docnames) keep = set(self.env.all_docs) - set(docnames)
try: try:
searchindexfn = path.join(self.outdir, self.searchindex_filename) searchindexfn = path.join(self.outdir, self.searchindex_filename)

View File

@ -79,7 +79,7 @@ class Index(object):
self.domain = domain self.domain = domain
def generate(self, docnames=None): def generate(self, docnames=None):
# type: (List[unicode]) -> Tuple[List[Tuple[unicode, List[List[Union[unicode, int]]]]], bool] # NOQA # type: (Iterable[unicode]) -> Tuple[List[Tuple[unicode, List[List[Union[unicode, int]]]]], bool] # NOQA
"""Return entries for the index given by *name*. If *docnames* is """Return entries for the index given by *name*. If *docnames* is
given, restrict to entries referring to these docnames. given, restrict to entries referring to these docnames.
@ -107,7 +107,7 @@ class Index(object):
Qualifier and description are not rendered e.g. in LaTeX output. Qualifier and description are not rendered e.g. in LaTeX output.
""" """
return [] return tuple()
class Domain(object): class Domain(object):

View File

@ -27,7 +27,7 @@ from sphinx.util.docfields import Field, GroupedField, TypedField
if False: if False:
# For type annotation # For type annotation
from typing import Any, Iterator, Tuple, Union # NOQA from typing import Any, Iterable, Iterator, Tuple, Union # NOQA
from sphinx.application import Sphinx # NOQA from sphinx.application import Sphinx # NOQA
from sphinx.builders import Builder # NOQA from sphinx.builders import Builder # NOQA
from sphinx.environment import BuildEnvironment # NOQA from sphinx.environment import BuildEnvironment # NOQA
@ -582,7 +582,7 @@ class PythonModuleIndex(Index):
shortname = l_('modules') shortname = l_('modules')
def generate(self, docnames=None): def generate(self, docnames=None):
# type: (List[unicode]) -> Tuple[List[Tuple[unicode, List[List[Union[unicode, int]]]]], bool] # NOQA # type: (Iterable[unicode]) -> Tuple[List[Tuple[unicode, List[List[Union[unicode, int]]]]], bool] # NOQA
content = {} # type: Dict[unicode, List] content = {} # type: Dict[unicode, List]
# list of prefixes to ignore # list of prefixes to ignore
ignores = None # type: List[unicode] ignores = None # type: List[unicode]

View File

@ -272,7 +272,7 @@ def load_mappings(app):
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
# new format # new format
name, (uri, inv) = key, value name, (uri, inv) = key, value # type: ignore
if not isinstance(name, string_types): if not isinstance(name, string_types):
logger.warning('intersphinx identifier %r is not string. Ignored', name) logger.warning('intersphinx identifier %r is not string. Ignored', name)
continue continue

View File

@ -88,7 +88,7 @@ class ParallelTasks(object):
failed = False failed = False
except BaseException as err: except BaseException as err:
failed = True failed = True
errmsg = traceback.format_exception_only(err.__class__, err)[0].strip() errmsg = traceback.format_exception_only(err.__class__, err)[0].strip() # type: ignore # NOQA
ret = (errmsg, traceback.format_exc()) ret = (errmsg, traceback.format_exc())
logging.convert_serializable(collector.logs) logging.convert_serializable(collector.logs)
pipe.send((failed, collector.logs, ret)) pipe.send((failed, collector.logs, ret))

View File

@ -22,7 +22,7 @@ try:
except ImportError: except ImportError:
# python-requests package in Debian jessie does not provide ``requests.packages.urllib3``. # python-requests package in Debian jessie does not provide ``requests.packages.urllib3``.
# So try to import the exceptions from urllib3 package. # So try to import the exceptions from urllib3 package.
from urllib3.exceptions import SSLError, InsecureRequestWarning from urllib3.exceptions import SSLError, InsecureRequestWarning # type: ignore
# try to load requests[security] # try to load requests[security]
try: try: