diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-03-03 12:19:09 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2017-03-03 23:17:34 +0900 |
commit | 554199d30e418f72f215fae65924b47249d2544c (patch) | |
tree | fd952e21a8f4e9dabf91c5e3731dea3712ade006 /sphinx/ext | |
parent | 28b1aceefedbb9c3a12d6ba7c712df8ad5e98db8 (diff) | |
download | sphinx-git-554199d30e418f72f215fae65924b47249d2544c.tar.gz |
Upgrade to mypy-0.5
Diffstat (limited to 'sphinx/ext')
-rw-r--r-- | sphinx/ext/autodoc.py | 8 | ||||
-rw-r--r-- | sphinx/ext/autosummary/__init__.py | 14 | ||||
-rw-r--r-- | sphinx/ext/autosummary/generate.py | 2 | ||||
-rw-r--r-- | sphinx/ext/coverage.py | 2 | ||||
-rw-r--r-- | sphinx/ext/doctest.py | 2 | ||||
-rw-r--r-- | sphinx/ext/graphviz.py | 2 | ||||
-rw-r--r-- | sphinx/ext/ifconfig.py | 2 | ||||
-rw-r--r-- | sphinx/ext/imgmath.py | 2 | ||||
-rw-r--r-- | sphinx/ext/inheritance_diagram.py | 4 | ||||
-rw-r--r-- | sphinx/ext/intersphinx.py | 4 | ||||
-rw-r--r-- | sphinx/ext/linkcode.py | 2 | ||||
-rw-r--r-- | sphinx/ext/mathbase.py | 2 | ||||
-rw-r--r-- | sphinx/ext/napoleon/__init__.py | 2 | ||||
-rw-r--r-- | sphinx/ext/napoleon/docstring.py | 28 | ||||
-rw-r--r-- | sphinx/ext/pngmath.py | 2 | ||||
-rw-r--r-- | sphinx/ext/todo.py | 2 | ||||
-rw-r--r-- | sphinx/ext/viewcode.py | 2 |
17 files changed, 42 insertions, 40 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 606953811..61b6197ca 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -40,7 +40,7 @@ from sphinx.util.docstrings import prepare_docstring if False: # For type annotation - from typing import Any, Callable, Iterator, Sequence, Tuple, Type, Union # NOQA + from typing import Any, Callable, Dict, Iterator, List, Sequence, Set, Tuple, Type, Union # NOQA from types import ModuleType # NOQA from docutils.utils import Reporter # NOQA from sphinx.application import Sphinx # NOQA @@ -482,7 +482,7 @@ class Documenter(object): #: true if the generated content may contain titles titles_allowed = False - option_spec = {'noindex': bool_option} + option_spec = {'noindex': bool_option} # type: Dict[unicode, Callable] @staticmethod def get_attr(obj, name, *defargs): @@ -1081,7 +1081,7 @@ class ModuleDocumenter(Documenter): 'member-order': identity, 'exclude-members': members_set_option, 'private-members': bool_option, 'special-members': members_option, 'imported-members': bool_option, - } + } # type: Dict[unicode, Callable] @classmethod def can_document_member(cls, member, membername, isattr, parent): @@ -1333,7 +1333,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: 'show-inheritance': bool_option, 'member-order': identity, 'exclude-members': members_set_option, 'private-members': bool_option, 'special-members': members_option, - } + } # type: Dict[unicode, Callable] @classmethod def can_document_member(cls, member, membername, isattr, parent): diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 7bf5ad5b8..7e29bf2ef 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -76,7 +76,7 @@ from sphinx.ext.autodoc import Options if False: # For type annotation - from typing import Any, Tuple, Type, Union # NOQA + from typing import Any, Dict, List, Tuple, Type, Union # NOQA from docutils.utils import Inliner # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA @@ -546,8 +546,7 @@ def _import_by_name(name): # -- :autolink: (smart default role) ------------------------------------------- -def autolink_role(typ, rawtext, etext, lineno, inliner, - options={}, content=[]): +def autolink_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]): # type: (unicode, unicode, unicode, int, Inliner, Dict, List[unicode]) -> Tuple[List[nodes.Node], List[nodes.Node]] # NOQA """Smart linking role. @@ -555,6 +554,7 @@ def autolink_role(typ, rawtext, etext, lineno, inliner, otherwise expands to '*text*'. """ env = inliner.document.settings.env + r = None # type: Tuple[List[nodes.Node], List[nodes.Node]] r = env.get_domain('py').role('obj')( 'obj', rawtext, etext, lineno, inliner, options, content) pnode = r[0][0] @@ -563,9 +563,9 @@ def autolink_role(typ, rawtext, etext, lineno, inliner, try: name, obj, parent, modname = import_by_name(pnode['reftarget'], prefixes) except ImportError: - content = pnode[0] - r[0][0] = nodes.emphasis(rawtext, content[0].astext(), # type: ignore - classes=content['classes']) # type: ignore + content_node = pnode[0] + r[0][0] = nodes.emphasis(rawtext, content_node[0].astext(), + classes=content_node['classes']) return r @@ -581,7 +581,7 @@ def get_rst_suffix(app): return parser_class.supported suffix = None # type: unicode - for suffix in app.config.source_suffix: # type: ignore + for suffix in app.config.source_suffix: if 'restructuredtext' in get_supported_format(suffix): return suffix diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index 1ef6628ac..a36eb3161 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -51,7 +51,7 @@ add_documenter(InstanceAttributeDocumenter) if False: # For type annotation - from typing import Any, Callable, Tuple, List # NOQA + from typing import Any, Callable, Dict, Tuple, List # NOQA from jinja2 import BaseLoader # NOQA from sphinx import addnodes # NOQA from sphinx.builders import Builder # NOQA diff --git a/sphinx/ext/coverage.py b/sphinx/ext/coverage.py index 1698f936b..3bf4ae2c4 100644 --- a/sphinx/ext/coverage.py +++ b/sphinx/ext/coverage.py @@ -25,7 +25,7 @@ from sphinx.util.inspect import safe_getattr if False: # For type annotation - from typing import Any, Callable, IO, Pattern, Tuple # NOQA + from typing import Any, Callable, Dict, IO, List, Pattern, Set, Tuple # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 73ce1a87c..38c1844ea 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -35,7 +35,7 @@ from sphinx.locale import _ if False: # For type annotation - from typing import Any, Callable, IO, Iterable, Sequence, Tuple # NOQA + from typing import Any, Callable, Dict, IO, Iterable, List, Sequence, Set, Tuple # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index 7df115ea0..bb8d76e21 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -32,7 +32,7 @@ from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL if False: # For type annotation - from typing import Any, Tuple # NOQA + from typing import Any, Dict, List, Tuple # NOQA from sphinx.application import Sphinx # NOQA logger = logging.getLogger(__name__) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index 430cc9325..eb50002ed 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -28,7 +28,7 @@ from sphinx.util.nodes import set_source_info if False: # For type annotation - from typing import Any # NOQA + from typing import Any, Dict, List # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/imgmath.py b/sphinx/ext/imgmath.py index 7b817d615..c95df0f37 100644 --- a/sphinx/ext/imgmath.py +++ b/sphinx/ext/imgmath.py @@ -33,7 +33,7 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath if False: # For type annotation - from typing import Any, Tuple # NOQA + from typing import Any, Dict, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.ext.mathbase import math as math_node, displaymath # NOQA diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index 3b23c845a..5ca939f93 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -45,7 +45,7 @@ except ImportError: from md5 import md5 # type: ignore from six import text_type -from six.moves import builtins # type: ignore +from six.moves import builtins from docutils import nodes from docutils.parsers.rst import Directive, directives @@ -58,7 +58,7 @@ from sphinx.util import force_decode if False: # For type annotation - from typing import Any, Tuple # NOQA + from typing import Any, Dict, List, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 4c8941134..246d69626 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -47,7 +47,7 @@ from sphinx.util import requests, logging if False: # For type annotation - from typing import Any, Callable, Dict, IO, Iterator, Tuple, Union # NOQA + from typing import Any, Callable, Dict, IO, Iterator, List, Tuple, Union # NOQA from sphinx.application import Sphinx # NOQA from sphinx.config import Config # NOQA from sphinx.environment import BuildEnvironment # NOQA @@ -173,6 +173,8 @@ def read_inventory(f, uri, join, bufsize=16 * 1024): return read_inventory_v1(f, uri, join) elif line == '# Sphinx inventory version 2': return read_inventory_v2(f, uri, join, bufsize=bufsize) + else: + raise ValueError('unknown inventory header: %s' % line) def _strip_basic_auth(url): diff --git a/sphinx/ext/linkcode.py b/sphinx/ext/linkcode.py index a9693299e..db8f2ea71 100644 --- a/sphinx/ext/linkcode.py +++ b/sphinx/ext/linkcode.py @@ -18,7 +18,7 @@ from sphinx.errors import SphinxError if False: # For type annotation - from typing import Any # NOQA + from typing import Any, Dict, Set # NOQA from sphinx.application import Sphinx # NOQA diff --git a/sphinx/ext/mathbase.py b/sphinx/ext/mathbase.py index 4e12f62f7..299b4bf9a 100644 --- a/sphinx/ext/mathbase.py +++ b/sphinx/ext/mathbase.py @@ -19,7 +19,7 @@ from sphinx.util.nodes import make_refnode, set_source_info if False: # For type annotation - from typing import Any, Callable, Iterable, Tuple # NOQA + from typing import Any, Callable, Dict, Iterable, List, Tuple # NOQA from docutils.parsers.rst.states import Inliner # NOQA from sphinx.application import Sphinx # NOQA from sphinx.builders import Builder # NOQA diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index 118316f07..87005736f 100644 --- a/sphinx/ext/napoleon/__init__.py +++ b/sphinx/ext/napoleon/__init__.py @@ -19,7 +19,7 @@ from sphinx.ext.napoleon.docstring import GoogleDocstring, NumpyDocstring if False: # For type annotation - from typing import Any # NOQA + from typing import Any, Dict, List # NOQA class Config(object): diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index c5736b8ec..704d94ff4 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -23,7 +23,7 @@ from sphinx.util.pycompat import UnicodeMixin if False: # For type annotation - from typing import Any, Callable, Tuple, Union # NOQA + from typing import Any, Callable, Dict, List, Tuple, Union # NOQA from sphinx.application import Sphinx # NOQA from sphinx.config import Config as SphinxConfig # NOQA @@ -234,9 +234,9 @@ class GoogleDocstring(UnicodeMixin): if prefer_type and not _type: _type, _name = _name, _type indent = self._get_indent(line) + 1 - _desc = [_desc] + self._dedent(self._consume_indented_block(indent)) # type: ignore - _desc = self.__class__(_desc, self._config).lines() - return _name, _type, _desc # type: ignore + _descs = [_desc] + self._dedent(self._consume_indented_block(indent)) + _descs = self.__class__(_descs, self._config).lines() + return _name, _type, _descs def _consume_fields(self, parse_type=True, prefer_type=False): # type: (bool, bool) -> List[Tuple[unicode, unicode, List[unicode]]] @@ -254,9 +254,9 @@ class GoogleDocstring(UnicodeMixin): _type, colon, _desc = self._partition_field_on_colon(line) if not colon: _type, _desc = _desc, _type - _desc = [_desc] + self._dedent(self._consume_to_end()) # type: ignore - _desc = self.__class__(_desc, self._config).lines() - return _type, _desc # type: ignore + _descs = [_desc] + self._dedent(self._consume_to_end()) + _descs = self.__class__(_descs, self._config).lines() + return _type, _descs def _consume_returns_section(self): # type: () -> List[Tuple[unicode, unicode, List[unicode]]] @@ -326,13 +326,13 @@ class GoogleDocstring(UnicodeMixin): def _fix_field_desc(self, desc): # type: (List[unicode]) -> List[unicode] if self._is_list(desc): - desc = [''] + desc # type: ignore + desc = [u''] + desc elif desc[0].endswith('::'): desc_block = desc[1:] indent = self._get_indent(desc[0]) block_indent = self._get_initial_indent(desc_block) if block_indent > indent: - desc = [''] + desc # type: ignore + desc = [u''] + desc else: desc = ['', desc[0]] + self._indent(desc_block, 4) return desc @@ -344,9 +344,9 @@ class GoogleDocstring(UnicodeMixin): return ['.. %s:: %s' % (admonition, lines[0].strip()), ''] elif lines: lines = self._indent(self._dedent(lines), 3) - return ['.. %s::' % admonition, ''] + lines + [''] # type: ignore + return [u'.. %s::' % admonition, u''] + lines + [u''] else: - return ['.. %s::' % admonition, ''] + return [u'.. %s::' % admonition, u''] def _format_block(self, prefix, lines, padding=None): # type: (unicode, List[unicode], unicode) -> List[unicode] @@ -566,8 +566,8 @@ class GoogleDocstring(UnicodeMixin): lines.append(':vartype %s: %s' % (_name, _type)) else: lines.extend(['.. attribute:: ' + _name, '']) - field = self._format_field('', _type, _desc) # type: ignore - lines.extend(self._indent(field, 3)) # type: ignore + fields = self._format_field('', _type, _desc) + lines.extend(self._indent(fields, 3)) lines.append('') if self._config.napoleon_use_ivar: lines.append('') @@ -617,7 +617,7 @@ class GoogleDocstring(UnicodeMixin): for _name, _, _desc in self._consume_fields(parse_type=False): lines.append('.. method:: %s' % _name) if _desc: - lines.extend([''] + self._indent(_desc, 3)) # type: ignore + lines.extend([u''] + self._indent(_desc, 3)) lines.append('') return lines diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index 98a4d2513..4b1743e51 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -33,7 +33,7 @@ from sphinx.ext.mathbase import setup_math as mathbase_setup, wrap_displaymath if False: # For type annotation - from typing import Any, Tuple # NOQA + from typing import Any, Dict, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.ext.mathbase import math as math_node, displaymath # NOQA diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index 430135721..98bd24ee7 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -25,7 +25,7 @@ from docutils.parsers.rst.directives.admonitions import BaseAdmonition if False: # For type annotation - from typing import Any, Iterable # NOQA + from typing import Any, Dict, Iterable, List # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py index c6b666a0a..0a4738b09 100644 --- a/sphinx/ext/viewcode.py +++ b/sphinx/ext/viewcode.py @@ -24,7 +24,7 @@ from sphinx.util.nodes import make_refnode if False: # For type annotation - from typing import Any, Iterable, Iterator, Tuple # NOQA + from typing import Any, Dict, Iterable, Iterator, Set, Tuple # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA |