mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove unused "type: ignore"
This commit is contained in:
parent
2e83241486
commit
029e9908c0
1
mypy.ini
1
mypy.ini
@ -4,3 +4,4 @@ silent_imports = True
|
||||
fast_parser = True
|
||||
incremental = True
|
||||
check_untyped_defs = True
|
||||
warn_unused_ignores = True
|
||||
|
@ -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)
|
||||
|
@ -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], [])
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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':
|
||||
|
@ -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]
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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-')
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 '<untitled>' # type: ignore
|
||||
elements['title'] = self.escape_id(title) or '<untitled>'
|
||||
# filename
|
||||
|
Loading…
Reference in New Issue
Block a user