diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-06-21 05:07:27 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-06-21 05:07:27 +0300 |
commit | 224d247ca0cc95b704f6007ba9556ae6925dae4b (patch) | |
tree | 63ef081e903799cc047aac824528740f0d828f9c | |
parent | 6595f65b0e9c03fb4dd306be5d7c9e742893475f (diff) |
Fix mypy violations (for mypy-0.710)
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | sphinx/domains/std.py | 9 | ||||
-rw-r--r-- | sphinx/util/inspect.py | 2 | ||||
-rw-r--r-- | sphinx/util/stemmer/__init__.py | 2 | ||||
-rw-r--r-- | sphinx/writers/latex.py | 2 | ||||
-rw-r--r-- | sphinx/writers/texinfo.py | 2 | ||||
-rw-r--r-- | sphinx/writers/text.py | 2 |
7 files changed, 11 insertions, 10 deletions
@@ -47,7 +47,7 @@ extras_require = { 'html5lib', 'flake8>=3.5.0', 'flake8-import-order', - 'mypy>=0.590', + 'mypy>=0.710', 'docutils-stubs', ], } diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 01cc797c3..45516ebd9 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -910,12 +910,13 @@ class StandardDomain(Domain): # type: (nodes.Node) -> str """Get the title of enumerable nodes to refer them using its title""" if self.is_enumerable_node(node): - _, title_getter = self.enumerable_nodes.get(node.__class__, (None, None)) + elem = cast(nodes.Element, node) + _, title_getter = self.enumerable_nodes.get(elem.__class__, (None, None)) if title_getter: - return title_getter(node) + return title_getter(elem) else: - for subnode in node: - if subnode.tagname in ('caption', 'title'): + for subnode in elem: + if isinstance(subnode, (nodes.caption, nodes.title)): return clean_astext(subnode) return None diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 42530eb40..c49708242 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -129,7 +129,7 @@ def isenumattribute(x): def ispartial(obj): # type: (Any) -> bool """Check if the object is partial.""" - return isinstance(obj, (partial, partialmethod)) + return isinstance(obj, (partial, partialmethod)) # type: ignore def isclassmethod(obj): diff --git a/sphinx/util/stemmer/__init__.py b/sphinx/util/stemmer/__init__.py index 047aac708..b9fb5c252 100644 --- a/sphinx/util/stemmer/__init__.py +++ b/sphinx/util/stemmer/__init__.py @@ -33,7 +33,7 @@ class PyStemmer(BaseStemmer): return self.stemmer.stemWord(word) -class StandardStemmer(PorterStemmer, BaseStemmer): # type: ignore +class StandardStemmer(PorterStemmer, BaseStemmer): """All those porter stemmer implementations look hideous; make at least the stem method nicer. """ diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 5c7f52507..24ec059e5 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -2598,7 +2598,7 @@ class LaTeXTranslator(SphinxTranslator): RemovedInSphinx30Warning) def visit_admonition(self, node): - # type: (nodes.Element) -> None + # type: (LaTeXTranslator, nodes.Element) -> None self.body.append('\n\\begin{sphinxadmonition}{%s}{%s:}' % (name, admonitionlabels[name])) return visit_admonition diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 4262ccd66..b952812f0 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -1752,6 +1752,6 @@ class TexinfoTranslator(SphinxTranslator): RemovedInSphinx30Warning) def visit(self, node): - # type: (nodes.Element) -> None + # type: (TexinfoTranslator, nodes.Element) -> None self.visit_admonition(node, admonitionlabels[name]) return visit diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py index 1447510c3..dc8a7963a 100644 --- a/sphinx/writers/text.py +++ b/sphinx/writers/text.py @@ -1375,6 +1375,6 @@ class TextTranslator(SphinxTranslator): RemovedInSphinx30Warning) def depart_admonition(self, node): - # type: (nodes.Element) -> None + # type: (TextTranslator, nodes.Element) -> None self.end_state(first=admonitionlabels[name] + ': ') return depart_admonition |