Merge pull request #5733 from tk0miya/fix_typehints_for_minor

Update type annotations
This commit is contained in:
Takeshi KOMIYA 2018-12-08 02:52:09 +09:00 committed by GitHub
commit 559c820214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 13 deletions

View File

@ -126,8 +126,9 @@ class CObject(ObjectDescription):
raise ValueError('no match')
rettype, name, arglist, const = m.groups()
signode += addnodes.desc_type('', '')
self._parse_type(signode[-1], rettype)
desc_type = addnodes.desc_type('', '')
signode += desc_type
self._parse_type(desc_type, rettype)
try:
classname, funcname = name.split('::', 1)
classname += '::'

View File

@ -87,8 +87,9 @@ class VersionChange(SphinxDirective):
content.line = node[0].line
content += node[0].children
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
node[0].insert(0, nodes.inline('', '%s: ' % text,
classes=['versionmodified']))
para = cast(nodes.paragraph, node[0])
para.insert(0, nodes.inline('', '%s: ' % text, classes=['versionmodified']))
else:
para = nodes.paragraph('', '',
nodes.inline('', '%s.' % text,

View File

@ -158,7 +158,7 @@ class ReSTDomain(Domain):
def resolve_any_xref(self, env, fromdocname, builder, target, node, contnode):
# type: (BuildEnvironment, unicode, Builder, unicode, addnodes.pending_xref, nodes.Element) -> List[Tuple[unicode, nodes.Element]] # NOQA
objects = self.data['objects']
results = []
results = [] # type: List[Tuple[unicode, nodes.Element]]
for objtype in self.object_types:
if (objtype, target) in self.data['objects']:
results.append(('rst:' + self.role_for_objtype(objtype),

View File

@ -593,7 +593,7 @@ class StandardDomain(Domain):
# type: (BuildEnvironment, unicode, nodes.document) -> None
for node in document.traverse(nodes.citation):
node['docname'] = docname
label = node[0].astext()
label = cast(nodes.label, node[0]).astext()
if label in self.data['citations']:
path = env.doc2path(self.data['citations'][label][0])
logger.warning(__('duplicate citation %s, other instance in %s'), label, path,
@ -634,7 +634,8 @@ class StandardDomain(Domain):
location=node)
anonlabels[name] = docname, labelid
if node.tagname in ('section', 'rubric'):
sectname = clean_astext(node[0]) # node[0] == title node
title = cast(nodes.title, node[0])
sectname = clean_astext(title)
elif self.is_enumerable_node(node):
sectname = self.get_numfig_title(node)
if not sectname:

View File

@ -596,7 +596,7 @@ class BuildEnvironment:
includehidden)
def resolve_references(self, doctree, fromdocname, builder):
# type: (nodes.Node, unicode, Builder) -> None
# type: (nodes.document, unicode, Builder) -> None
self.apply_post_transforms(doctree, fromdocname)
def apply_post_transforms(self, doctree, docname):

View File

@ -87,7 +87,7 @@ class TocTree:
excluded = Matcher(self.env.config.exclude_patterns)
def _toctree_add_classes(node, depth):
# type: (nodes.Node, int) -> None
# type: (nodes.Element, int) -> None
"""Add 'toctree-l%d' and 'current' classes to the toctree."""
for subnode in node.children:
if isinstance(subnode, (addnodes.compact_paragraph,

View File

@ -635,9 +635,8 @@ def autolink_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]):
try:
name, obj, parent, modname = import_by_name(pending_xref['reftarget'], prefixes)
except ImportError:
contnode = pending_xref[0]
objects[0] = nodes.emphasis(rawtext, contnode[0].astext(),
classes=contnode['classes'])
literal = cast(nodes.literal, pending_xref[0])
objects[0] = nodes.emphasis(rawtext, literal.astext(), classes=literal['classes'])
return objects, msg

View File

@ -67,7 +67,7 @@ class NestedInlineTransform:
def apply(self, **kwargs):
# type: (Any) -> None
matcher = NodeMatcher(nodes.literal, nodes.emphasis, nodes.strong)
for node in self.document.traverse(matcher): # type: nodes.Element
for node in self.document.traverse(matcher): # type: nodes.TextElement
if any(matcher(subnode) for subnode in node):
pos = node.parent.index(node)
for subnode in reversed(node[1:]):
@ -410,6 +410,8 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator):
bullet_list = cast(nodes.bullet_list, node[0])
list_items = cast(Iterable[nodes.list_item], bullet_list)
self.ensure_eol()
bullet_list = cast(nodes.bullet_list, node[0])
list_items = cast(Iterable[nodes.list_item], bullet_list)
self.body.append(', '.join(n.astext() for n in list_items) + '.')
self.body.append('\n')
raise nodes.SkipNode