diff --git a/mypy.ini b/mypy.ini index 17ded7ab8..f7b58a613 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,3 +4,4 @@ silent_imports = True fast_parser = True incremental = True check_untyped_defs = True +warn_unused_ignores = True diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index dbeca1a34..be86b7cb1 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -398,7 +398,7 @@ class Builder(object): self.write_doc(docname, doctree) # warm up caches/compile templates using the first document - firstname, docnames = docnames[0], docnames[1:] # type: ignore + firstname, docnames = docnames[0], docnames[1:] doctree = self.env.get_and_resolve_doctree(firstname, self) self.write_doc_serialized(firstname, doctree) self.write_doc(firstname, doctree) diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py index 031c55184..36a604188 100644 --- a/sphinx/builders/devhelp.py +++ b/sphinx/builders/devhelp.py @@ -121,7 +121,7 @@ class DevhelpBuilder(StandaloneHTMLBuilder): link=ref[1]) if subitems: - parent_title = re.sub(r'\s*\(.*\)\s*$', '', title) # type: ignore + parent_title = re.sub(r'\s*\(.*\)\s*$', '', title) for subitem in subitems: write_index("%s %s" % (parent_title, subitem[0]), subitem[1], []) diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 062c56669..46daef97c 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -191,7 +191,7 @@ class StandaloneHTMLBuilder(Builder): else: self.translator_class = HTMLTranslator - def get_outdated_docs(self): # type: ignore + def get_outdated_docs(self): # type: () -> Iterator[unicode] cfgdict = dict((confval.name, confval.value) for confval in self.config.filter('html')) self.config_hash = get_stable_hash(cfgdict) diff --git a/sphinx/config.py b/sphinx/config.py index f5867f40f..12f206f96 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -171,8 +171,7 @@ class Config(object): if getenv('SOURCE_DATE_EPOCH') is not None: for k in ('copyright', 'epub_copyright'): if k in config: - config[k] = copyright_year_re.sub('\g<1>%s' % format_date('%Y'), # type: ignore # NOQA - config[k]) + config[k] = copyright_year_re.sub('\g<1>%s' % format_date('%Y'), config[k]) def check_types(self): # type: () -> None @@ -221,7 +220,7 @@ class Config(object): # check all string values for non-ASCII characters in bytestrings, # since that can result in UnicodeErrors all over the place for name, value in iteritems(self._raw_config): - if isinstance(value, binary_type) and nonascii_re.search(value): # type: ignore + if isinstance(value, binary_type) and nonascii_re.search(value): logger.warning('the config value %r is set to a string with non-ASCII ' 'characters; this can lead to Unicode errors occurring. ' 'Please use Unicode strings, e.g. %r.', name, u'Content') @@ -272,7 +271,7 @@ class Config(object): try: if '.' in valname: realvalname, key = valname.split('.', 1) - config.setdefault(realvalname, {})[key] = value # type: ignore + config.setdefault(realvalname, {})[key] = value continue elif valname not in self.values: logger.warning('unknown config value %r in override, ignoring', valname) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index aa26df405..dd6b23b3e 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -4544,7 +4544,7 @@ class CPPObject(ObjectDescription): # type: (Any) -> Any raise NotImplementedError() - def describe_signature(self, signode, ast, options): # type: ignore + def describe_signature(self, signode, ast, options): # type: (addnodes.desc_signature, Any, Dict) -> None ast.describe_signature(signode, 'lastIsName', self.env, options) diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 688062be6..2467e85ef 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -191,7 +191,7 @@ class PyObject(ObjectDescription): """ return False - def handle_signature(self, sig, signode): # type: ignore + def handle_signature(self, sig, signode): # type: (unicode, addnodes.desc_signature) -> Tuple[unicode, unicode] """Transform a Python signature into RST nodes. diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 300fc9c19..1c064ee65 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -776,8 +776,8 @@ class StandardDomain(Domain): docname, labelid = self.data['progoptions'].get((progname, target), ('', '')) if not docname: commands = [] - while ws_re.search(target): # type: ignore - subcommand, target = ws_re.split(target, 1) # type: ignore + while ws_re.search(target): + subcommand, target = ws_re.split(target, 1) commands.append(subcommand) progname = "-".join(commands) diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 01ced26de..cab900421 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1538,11 +1538,11 @@ class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: # to distinguish classmethod/staticmethod obj = self.parent.__dict__.get(self.object_name) - if isinstance(obj, classmethod): # type: ignore + if isinstance(obj, classmethod): self.directivetype = 'classmethod' # document class and static members before ordinary ones self.member_order = self.member_order - 1 - elif isinstance(obj, staticmethod): # type: ignore + elif isinstance(obj, staticmethod): self.directivetype = 'staticmethod' # document class and static members before ordinary ones self.member_order = self.member_order - 1 diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index 984642312..a918a925c 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -128,7 +128,7 @@ class TestDirective(Directive): option_strings = self.options['options'].replace(',', ' ').split() for option in option_strings: prefix, option_name = option[0], option[1:] - if prefix not in '+-': # type: ignore + if prefix not in '+-': self.state.document.reporter.warning( _("missing '+' or '-' in '%s' option.") % option, line=self.lineno) diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index 297e476f5..430cc9325 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -62,7 +62,7 @@ def process_ifconfig_nodes(app, doctree, docname): ns['builder'] = app.builder.name for node in doctree.traverse(ifconfig): try: - res = eval(node['expr'], ns) # type: ignore + res = eval(node['expr'], ns) except Exception as err: # handle exceptions in a clean fashion from traceback import format_exception_only diff --git a/sphinx/ext/imgmath.py b/sphinx/ext/imgmath.py index 168862d28..7b817d615 100644 --- a/sphinx/ext/imgmath.py +++ b/sphinx/ext/imgmath.py @@ -128,7 +128,7 @@ def render_math(self, math): else: tempdir = self.builder._imgmath_tempdir - with codecs.open(path.join(tempdir, 'math.tex'), 'w', 'utf-8') as tf: # type: ignore + with codecs.open(path.join(tempdir, 'math.tex'), 'w', 'utf-8') as tf: tf.write(latex) # build latex command; old versions of latex don't have the diff --git a/sphinx/ext/intersphinx.py b/sphinx/ext/intersphinx.py index 818fdf68a..5493e6782 100644 --- a/sphinx/ext/intersphinx.py +++ b/sphinx/ext/intersphinx.py @@ -69,19 +69,19 @@ class InventoryAdapter(object): self.env = env if not hasattr(env, 'intersphinx_cache'): - self.env.intersphinx_cache = {} # type: ignore - self.env.intersphinx_inventory = {} # type: ignore - self.env.intersphinx_named_inventory = {} # type: ignore + self.env.intersphinx_cache = {} + self.env.intersphinx_inventory = {} + self.env.intersphinx_named_inventory = {} @property def cache(self): # type: () -> Dict[unicode, Tuple[unicode, int, Inventory]] - return self.env.intersphinx_cache # type: ignore + return self.env.intersphinx_cache @property def main_inventory(self): # type: () -> Inventory - return self.env.intersphinx_inventory # type: ignore + return self.env.intersphinx_inventory @property def named_inventory(self): diff --git a/sphinx/ext/napoleon/__init__.py b/sphinx/ext/napoleon/__init__.py index f6fccac7d..118316f07 100644 --- a/sphinx/ext/napoleon/__init__.py +++ b/sphinx/ext/napoleon/__init__.py @@ -290,8 +290,7 @@ def setup(app): """ if not isinstance(app, Sphinx): - return # type: ignore - # probably called by tests + return # probably called by tests _patch_python_domain() @@ -311,7 +310,7 @@ def _patch_python_domain(): pass else: import sphinx.domains.python - import sphinx.locale # type: ignore + import sphinx.locale l_ = sphinx.locale.lazy_gettext for doc_field in sphinx.domains.python.PyObject.doc_field_types: if doc_field.name == 'parameter': diff --git a/sphinx/ext/napoleon/docstring.py b/sphinx/ext/napoleon/docstring.py index 6fee87b34..c5736b8ec 100644 --- a/sphinx/ext/napoleon/docstring.py +++ b/sphinx/ext/napoleon/docstring.py @@ -128,7 +128,7 @@ class GoogleDocstring(UnicodeMixin): self._obj = obj self._opt = options if isinstance(docstring, string_types): - docstring = docstring.splitlines() # type: ignore + docstring = docstring.splitlines() self._lines = docstring self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip()) self._parsed_lines = [] # type: List[unicode] diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index 0bc941ee2..98a4d2513 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -119,7 +119,7 @@ def render_math(self, math): else: tempdir = self.builder._mathpng_tempdir - with codecs.open(path.join(tempdir, 'math.tex'), 'w', 'utf-8') as tf: # type: ignore + with codecs.open(path.join(tempdir, 'math.tex'), 'w', 'utf-8') as tf: tf.write(latex) # build latex command; old versions of latex don't have the diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index c1bd04765..6ebb1353f 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -33,7 +33,7 @@ if False: def _tobool(val): # type: (unicode) -> bool if isinstance(val, string_types): - return val.lower() in ('true', '1', 'yes', 'on') # type: ignore + return val.lower() in ('true', '1', 'yes', 'on') return bool(val) diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py index aff6aec34..658cf2f70 100644 --- a/sphinx/search/__init__.py +++ b/sphinx/search/__init__.py @@ -315,7 +315,7 @@ class IndexBuilder(object): """Dump the frozen index to a stream.""" if isinstance(format, string_types): format = self.formats[format] # type: ignore - format.dump(self.freeze(), stream) # type: ignore + format.dump(self.freeze(), stream) def get_objects(self, fn2index): # type: (Dict[unicode, int]) -> Dict[unicode, Dict[unicode, Tuple[int, int, int, unicode]]] # NOQA diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 5fb42b9d5..3b1f076a9 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -207,7 +207,7 @@ def save_traceback(app): import platform exc = sys.exc_info()[1] if isinstance(exc, SphinxParallelError): - exc_format = '(Error in parallel process)\n' + exc.traceback # type: ignore + exc_format = '(Error in parallel process)\n' + exc.traceback else: exc_format = traceback.format_exc() fd, path = tempfile.mkstemp('.log', 'sphinx-err-') diff --git a/sphinx/util/i18n.py b/sphinx/util/i18n.py index e4f1d95f5..bb6896080 100644 --- a/sphinx/util/i18n.py +++ b/sphinx/util/i18n.py @@ -95,7 +95,7 @@ def find_catalog_files(docname, srcdir, locale_dirs, lang, compaction): domain = find_catalog(docname, compaction) files = [gettext.find(domain, path.join(srcdir, dir_), [lang]) # type: ignore - for dir_ in locale_dirs] # type: ignore + for dir_ in locale_dirs] files = [path.relpath(f, srcdir) for f in files if f] # type: ignore return files # type: ignore diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 07a0e1e83..741009995 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -248,7 +248,7 @@ class TexinfoTranslator(nodes.NodeVisitor): title = None # type: unicode title = elements['title'] # type: ignore if not title: - title = self.document.next_node(nodes.title) # type: ignore + title = self.document.next_node(nodes.title) title = (title and title.astext()) or '' # type: ignore elements['title'] = self.escape_id(title) or '' # filename