summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-10-06 18:18:12 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-10-06 18:21:27 +0900
commitaf09cd0e359887d50c8c102808bf9b71eca3d36d (patch)
treeec155b73993f64b1aef4fd003bfd1d7dcb46d1a0
parent8912ee0af0734e92b69a947a22b31c5a1187e584 (diff)
downloadsphinx-git-af09cd0e359887d50c8c102808bf9b71eca3d36d.tar.gz
Fix mypy violations (for mypy-0.730)
-rw-r--r--setup.py2
-rw-r--r--sphinx/builders/html.py4
-rw-r--r--sphinx/cmd/make_mode.py2
-rw-r--r--sphinx/ext/doctest.py4
-rw-r--r--sphinx/ext/inheritance_diagram.py2
-rw-r--r--sphinx/ext/intersphinx.py4
-rw-r--r--sphinx/io.py4
-rw-r--r--sphinx/locale/__init__.py2
-rw-r--r--sphinx/testing/util.py8
-rw-r--r--sphinx/util/__init__.py2
-rw-r--r--sphinx/util/docutils.py16
-rw-r--r--sphinx/util/inspect.py8
-rw-r--r--sphinx/writers/texinfo.py4
13 files changed, 31 insertions, 31 deletions
diff --git a/setup.py b/setup.py
index f92de9250..1f3999490 100644
--- a/setup.py
+++ b/setup.py
@@ -47,7 +47,7 @@ extras_require = {
'html5lib',
'flake8>=3.5.0',
'flake8-import-order',
- 'mypy>=0.720',
+ 'mypy>=0.730',
'docutils-stubs',
],
}
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py
index ea005204c..ee071ed5d 100644
--- a/sphinx/builders/html.py
+++ b/sphinx/builders/html.py
@@ -90,7 +90,7 @@ class Stylesheet(str):
attributes = None # type: Dict[str, str]
filename = None # type: str
- def __new__(cls, filename: str, *args: str, **attributes: str) -> None:
+ def __new__(cls, filename: str, *args: str, **attributes: str) -> "Stylesheet":
self = str.__new__(cls, filename) # type: ignore
self.filename = filename
self.attributes = attributes
@@ -142,7 +142,7 @@ class JavaScript(str):
attributes = None # type: Dict[str, str]
filename = None # type: str
- def __new__(cls, filename: str, **attributes: str) -> None:
+ def __new__(cls, filename: str, **attributes: str) -> "JavaScript":
self = str.__new__(cls, filename) # type: ignore
self.filename = filename
self.attributes = attributes
diff --git a/sphinx/cmd/make_mode.py b/sphinx/cmd/make_mode.py
index 508b60959..682fe8d6c 100644
--- a/sphinx/cmd/make_mode.py
+++ b/sphinx/cmd/make_mode.py
@@ -88,7 +88,7 @@ class Make:
nocolor()
print(bold("Sphinx v%s" % sphinx.__display_version__))
- print("Please use `make %s' where %s is one of" % ((blue('target'),) * 2)) # type: ignore # NOQA
+ print("Please use `make %s' where %s is one of" % ((blue('target'),) * 2))
for osname, bname, description in BUILDERS:
if not osname or os.name == osname:
print(' %s %s' % (blue(bname.ljust(10)), description))
diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py
index 391de73b7..996f8394f 100644
--- a/sphinx/ext/doctest.py
+++ b/sphinx/ext/doctest.py
@@ -286,7 +286,7 @@ class DocTestBuilder(Builder):
# for doctest examples but unusable for multi-statement code such
# as setup code -- to be able to use doctest error reporting with
# that code nevertheless, we monkey-patch the "compile" it uses.
- doctest.compile = self.compile
+ doctest.compile = self.compile # type: ignore
sys.path[0:0] = self.config.doctest_path
@@ -507,7 +507,7 @@ Doctest summary
if len(code) == 1:
# ordinary doctests (code/output interleaved)
try:
- test = parser.get_doctest(code[0].code, {}, group.name, # type: ignore
+ test = parser.get_doctest(code[0].code, {}, group.name,
code[0].filename, code[0].lineno)
except Exception:
logger.warning(__('ignoring invalid doctest code: %r'), code[0].code,
diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py
index ecb6302d1..27685a045 100644
--- a/sphinx/ext/inheritance_diagram.py
+++ b/sphinx/ext/inheritance_diagram.py
@@ -368,7 +368,7 @@ class InheritanceDiagram(SphinxDirective):
# removed from the doctree after we're done with them.
for name in graph.get_all_class_names():
refnodes, x = class_role( # type: ignore
- 'class', ':class:`%s`' % name, name, 0, self.state)
+ 'class', ':class:`%s`' % name, name, 0, self.state) # type: ignore
node.extend(refnodes)
# Store the graph object so we can use it to generate the
# dot file later
diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py
index e76e0836e..cb74ef6f1 100644
--- a/sphinx/ext/intersphinx.py
+++ b/sphinx/ext/intersphinx.py
@@ -398,7 +398,7 @@ def inspect_main(argv: List[str]) -> None:
if __name__ == '__main__':
- import logging # type: ignore
- logging.basicConfig()
+ import logging as _logging
+ _logging.basicConfig()
inspect_main(argv=sys.argv[1:])
diff --git a/sphinx/io.py b/sphinx/io.py
index 5bf2d60da..80c03bb51 100644
--- a/sphinx/io.py
+++ b/sphinx/io.py
@@ -306,10 +306,10 @@ def read_doc(app, env, filename):
# Sphinx-1.8 style
source = input_class(app, env, source=None, source_path=filename, # type: ignore
encoding=env.config.source_encoding)
- pub = Publisher(reader=reader, # type: ignore
+ pub = Publisher(reader=reader,
parser=parser,
writer=SphinxDummyWriter(),
- source_class=SphinxDummySourceClass,
+ source_class=SphinxDummySourceClass, # type: ignore
destination=NullOutput())
pub.process_programmatic_settings(None, env.settings, None)
pub.set_source(source, filename)
diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py
index 6ae20d0d0..90355f87f 100644
--- a/sphinx/locale/__init__.py
+++ b/sphinx/locale/__init__.py
@@ -35,7 +35,7 @@ class _TranslationProxy(UserString):
"""
__slots__ = ('_func', '_args')
- def __new__(cls, func, *args):
+ def __new__(cls, func, *args): # type: ignore
# type: (Callable, str) -> object
if not args:
# not called with "function" and "arguments", but a plain string
diff --git a/sphinx/testing/util.py b/sphinx/testing/util.py
index f7ce33eac..1ba3237c4 100644
--- a/sphinx/testing/util.py
+++ b/sphinx/testing/util.py
@@ -120,8 +120,8 @@ class SphinxTestApp(application.Sphinx):
warningiserror = False
self._saved_path = sys.path[:]
- self._saved_directives = directives._directives.copy()
- self._saved_roles = roles._roles.copy()
+ self._saved_directives = directives._directives.copy() # type: ignore
+ self._saved_roles = roles._roles.copy() # type: ignore
self._saved_nodeclasses = {v for v in dir(nodes.GenericNodeVisitor)
if v.startswith('visit_')}
@@ -140,8 +140,8 @@ class SphinxTestApp(application.Sphinx):
locale.translators.clear()
sys.path[:] = self._saved_path
sys.modules.pop('autodoc_fodder', None)
- directives._directives = self._saved_directives
- roles._roles = self._saved_roles
+ directives._directives = self._saved_directives # type: ignore
+ roles._roles = self._saved_roles # type: ignore
for method in dir(nodes.GenericNodeVisitor):
if method.startswith('visit_') and \
method not in self._saved_nodeclasses:
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index b75e80034..19ffec633 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -252,7 +252,7 @@ def save_traceback(app: "Sphinx") -> str:
platform.python_version(),
platform.python_implementation(),
docutils.__version__, docutils.__version_details__,
- jinja2.__version__,
+ jinja2.__version__, # type: ignore
last_msgs)).encode())
if app is not None:
for ext in app.extensions.values():
diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py
index d4d808968..0f732411c 100644
--- a/sphinx/util/docutils.py
+++ b/sphinx/util/docutils.py
@@ -54,13 +54,13 @@ additional_nodes = set() # type: Set[Type[nodes.Element]]
def docutils_namespace() -> Generator[None, None, None]:
"""Create namespace for reST parsers."""
try:
- _directives = copy(directives._directives)
- _roles = copy(roles._roles)
+ _directives = copy(directives._directives) # type: ignore
+ _roles = copy(roles._roles) # type: ignore
yield
finally:
- directives._directives = _directives
- roles._roles = _roles
+ directives._directives = _directives # type: ignore
+ roles._roles = _roles # type: ignore
for node in list(additional_nodes):
unregister_node(node)
@@ -69,7 +69,7 @@ def docutils_namespace() -> Generator[None, None, None]:
def is_directive_registered(name: str) -> bool:
"""Check the *name* directive is already registered."""
- return name in directives._directives
+ return name in directives._directives # type: ignore
def register_directive(name: str, directive: "Type[Directive]") -> None:
@@ -83,7 +83,7 @@ def register_directive(name: str, directive: "Type[Directive]") -> None:
def is_role_registered(name: str) -> bool:
"""Check the *name* role is already registered."""
- return name in roles._roles
+ return name in roles._roles # type: ignore
def register_role(name: str, role: RoleFunction) -> None:
@@ -97,7 +97,7 @@ def register_role(name: str, role: RoleFunction) -> None:
def unregister_role(name: str) -> None:
"""Unregister a role from docutils."""
- roles._roles.pop(name, None)
+ roles._roles.pop(name, None) # type: ignore
def is_node_registered(node: "Type[Element]") -> bool:
@@ -112,7 +112,7 @@ def register_node(node: "Type[Element]") -> None:
inside ``docutils_namespace()`` to prevent side-effects.
"""
if not hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__):
- nodes._add_node_class_names([node.__name__])
+ nodes._add_node_class_names([node.__name__]) # type: ignore
additional_nodes.add(node)
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 2a6c0018e..20af75628 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -546,7 +546,7 @@ class Signature:
else:
qualname = repr(annotation)
- if (isinstance(annotation, typing.TupleMeta) and
+ if (isinstance(annotation, typing.TupleMeta) and # type: ignore
not hasattr(annotation, '__tuple_params__')): # for Python 3.6
params = annotation.__args__
if params:
@@ -572,7 +572,7 @@ class Signature:
param_str = ', '.join(self.format_annotation(p) for p in params)
return '%s[%s]' % (qualname, param_str)
elif (hasattr(typing, 'UnionMeta') and
- isinstance(annotation, typing.UnionMeta) and
+ isinstance(annotation, typing.UnionMeta) and # type: ignore
hasattr(annotation, '__union_params__')): # for Python 3.5
params = annotation.__union_params__
if params is not None:
@@ -590,7 +590,7 @@ class Signature:
else:
param_str = ', '.join(self.format_annotation(p) for p in params)
return 'Union[%s]' % param_str
- elif (isinstance(annotation, typing.CallableMeta) and
+ elif (isinstance(annotation, typing.CallableMeta) and # type: ignore
getattr(annotation, '__args__', None) is not None and
hasattr(annotation, '__result__')): # for Python 3.5
# Skipped in the case of plain typing.Callable
@@ -605,7 +605,7 @@ class Signature:
return '%s[%s, %s]' % (qualname,
args_str,
self.format_annotation(annotation.__result__))
- elif (isinstance(annotation, typing.TupleMeta) and
+ elif (isinstance(annotation, typing.TupleMeta) and # type: ignore
hasattr(annotation, '__tuple_params__') and
hasattr(annotation, '__tuple_use_ellipsis__')): # for Python 3.5
params = annotation.__tuple_params__
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py
index b952812f0..0164465f7 100644
--- a/sphinx/writers/texinfo.py
+++ b/sphinx/writers/texinfo.py
@@ -212,7 +212,7 @@ class TexinfoTranslator(SphinxTranslator):
for index in self.indices:
name, content = index
pointers = tuple([name] + self.rellinks[name])
- self.body.append('\n@node %s,%s,%s,%s\n' % pointers) # type: ignore
+ self.body.append('\n@node %s,%s,%s,%s\n' % pointers)
self.body.append('@unnumbered %s\n\n%s\n' % (name, content))
while self.referenced_ids:
@@ -618,7 +618,7 @@ class TexinfoTranslator(SphinxTranslator):
node_name = node['node_name']
pointers = tuple([node_name] + self.rellinks[node_name])
- self.body.append('\n@node %s,%s,%s,%s\n' % pointers) # type: ignore
+ self.body.append('\n@node %s,%s,%s,%s\n' % pointers)
for id in sorted(self.next_section_ids):
self.add_anchor(id, node)