Merge branch 'stable'

This commit is contained in:
Takeshi KOMIYA 2017-07-15 16:46:59 +09:00
commit f349d18531
4 changed files with 19 additions and 19 deletions

View File

@ -248,7 +248,7 @@ class Sphinx(object):
user_locale_dirs, self.config.language, domains=['sphinx'], user_locale_dirs, self.config.language, domains=['sphinx'],
charset=self.config.source_encoding): charset=self.config.source_encoding):
catinfo.write_mo(self.config.language) catinfo.write_mo(self.config.language)
locale_dirs = [None, path.join(package_dir, 'locale')] + user_locale_dirs locale_dirs = [None, path.join(package_dir, 'locale')] + user_locale_dirs # type: ignore
else: else:
locale_dirs = [] locale_dirs = []
self.translator, has_translation = locale.init(locale_dirs, self.config.language) self.translator, has_translation = locale.init(locale_dirs, self.config.language)

View File

@ -591,7 +591,7 @@ class Documenter(object):
self.add_line(line, src[0], src[1]) self.add_line(line, src[0], src[1])
def get_object_members(self, want_all): def get_object_members(self, want_all):
# type: (bool) -> Tuple[bool, List[Tuple[unicode, object]]] # type: (bool) -> Tuple[bool, List[Tuple[unicode, Any]]]
"""Return `(members_check_module, members)` where `members` is a """Return `(members_check_module, members)` where `members` is a
list of `(membername, member)` pairs of the members of *self.object*. list of `(membername, member)` pairs of the members of *self.object*.

View File

@ -134,12 +134,12 @@ class TestDirective(Directive):
_("missing '+' or '-' in '%s' option.") % option, _("missing '+' or '-' in '%s' option.") % option,
line=self.lineno) line=self.lineno)
continue continue
if option_name not in doctest.OPTIONFLAGS_BY_NAME: # type: ignore if option_name not in doctest.OPTIONFLAGS_BY_NAME:
self.state.document.reporter.warning( self.state.document.reporter.warning(
_("'%s' is not a valid option.") % option_name, _("'%s' is not a valid option.") % option_name,
line=self.lineno) line=self.lineno)
continue continue
flag = doctest.OPTIONFLAGS_BY_NAME[option[1:]] # type: ignore flag = doctest.OPTIONFLAGS_BY_NAME[option[1:]]
node['options'][flag] = (option[0] == '+') node['options'][flag] = (option[0] == '+')
if self.name == 'doctest' and 'pyversion' in self.options: if self.name == 'doctest' and 'pyversion' in self.options:
try: try:
@ -148,7 +148,7 @@ class TestDirective(Directive):
operand, option_version = [item.strip() for item in option.split()] operand, option_version = [item.strip() for item in option.split()]
running_version = platform.python_version() running_version = platform.python_version()
if not compare_version(running_version, option_version, operand): if not compare_version(running_version, option_version, operand):
flag = doctest.OPTIONFLAGS_BY_NAME['SKIP'] # type: ignore flag = doctest.OPTIONFLAGS_BY_NAME['SKIP']
node['options'][flag] = True # Skip the test node['options'][flag] = True # Skip the test
except ValueError: except ValueError:
self.state.document.reporter.warning( self.state.document.reporter.warning(
@ -188,7 +188,7 @@ class TestoutputDirective(TestDirective):
} }
parser = doctest.DocTestParser() # type: ignore parser = doctest.DocTestParser()
# helper classes # helper classes
@ -240,14 +240,14 @@ class TestCode(object):
self.code, self.type, self.lineno, self.options) self.code, self.type, self.lineno, self.options)
class SphinxDocTestRunner(doctest.DocTestRunner): # type: ignore class SphinxDocTestRunner(doctest.DocTestRunner):
def summarize(self, out, verbose=None): def summarize(self, out, verbose=None): # type: ignore
# type: (Callable, bool) -> Tuple[int, int] # type: (Callable, bool) -> Tuple[int, int]
string_io = StringIO() string_io = StringIO()
old_stdout = sys.stdout old_stdout = sys.stdout
sys.stdout = string_io sys.stdout = string_io
try: try:
res = doctest.DocTestRunner.summarize(self, verbose) # type: ignore res = doctest.DocTestRunner.summarize(self, verbose)
finally: finally:
sys.stdout = old_stdout sys.stdout = old_stdout
out(string_io.getvalue()) out(string_io.getvalue())
@ -257,7 +257,7 @@ class SphinxDocTestRunner(doctest.DocTestRunner): # type: ignore
module_globals=None): module_globals=None):
# type: (unicode, Any) -> Any # type: (unicode, Any) -> Any
# this is overridden from DocTestRunner adding the try-except below # this is overridden from DocTestRunner adding the try-except below
m = self._DocTestRunner__LINECACHE_FILENAME_RE.match(filename) m = self._DocTestRunner__LINECACHE_FILENAME_RE.match(filename) # type: ignore
if m and m.group('name') == self.test.name: if m and m.group('name') == self.test.name:
try: try:
example = self.test.examples[int(m.group('examplenum'))] example = self.test.examples[int(m.group('examplenum'))]
@ -268,7 +268,7 @@ class SphinxDocTestRunner(doctest.DocTestRunner): # type: ignore
pass pass
else: else:
return example.source.splitlines(True) return example.source.splitlines(True)
return self.save_linecache_getlines(filename, module_globals) return self.save_linecache_getlines(filename, module_globals) # type: ignore
# the new builder -- use sphinx-build.py -b doctest to run # the new builder -- use sphinx-build.py -b doctest to run
@ -379,8 +379,8 @@ Doctest summary
self.cleanup_runner = SphinxDocTestRunner(verbose=False, self.cleanup_runner = SphinxDocTestRunner(verbose=False,
optionflags=self.opt) optionflags=self.opt)
self.test_runner._fakeout = self.setup_runner._fakeout self.test_runner._fakeout = self.setup_runner._fakeout # type: ignore
self.cleanup_runner._fakeout = self.setup_runner._fakeout self.cleanup_runner._fakeout = self.setup_runner._fakeout # type: ignore
if self.config.doctest_test_doctest_blocks: if self.config.doctest_test_doctest_blocks:
def condition(node): def condition(node):
@ -466,7 +466,7 @@ Doctest summary
if not examples: if not examples:
return True return True
# simulate a doctest with the code # simulate a doctest with the code
sim_doctest = doctest.DocTest(examples, {}, # type: ignore sim_doctest = doctest.DocTest(examples, {},
'%s (%s code)' % (group.name, what), '%s (%s code)' % (group.name, what),
filename_str, 0, None) filename_str, 0, None)
sim_doctest.globs = ns sim_doctest.globs = ns
@ -487,7 +487,7 @@ Doctest summary
if len(code) == 1: if len(code) == 1:
# ordinary doctests (code/output interleaved) # ordinary doctests (code/output interleaved)
try: try:
test = parser.get_doctest( test = parser.get_doctest( # type: ignore
doctest_encode(code[0].code, self.env.config.source_encoding), {}, # type: ignore # NOQA doctest_encode(code[0].code, self.env.config.source_encoding), {}, # type: ignore # NOQA
group.name, filename_str, code[0].lineno) group.name, filename_str, code[0].lineno)
except Exception: except Exception:
@ -507,9 +507,9 @@ Doctest summary
output = code[1] and code[1].code or '' output = code[1] and code[1].code or ''
options = code[1] and code[1].options or {} options = code[1] and code[1].options or {}
# disable <BLANKLINE> processing as it is not needed # disable <BLANKLINE> processing as it is not needed
options[doctest.DONT_ACCEPT_BLANKLINE] = True # type: ignore options[doctest.DONT_ACCEPT_BLANKLINE] = True
# find out if we're testing an exception # find out if we're testing an exception
m = parser._EXCEPTION_RE.match(output) m = parser._EXCEPTION_RE.match(output) # type: ignore
if m: if m:
exc_msg = m.group('msg') exc_msg = m.group('msg')
else: else:
@ -546,6 +546,6 @@ def setup(app):
app.add_config_value('doctest_global_cleanup', '', False) app.add_config_value('doctest_global_cleanup', '', False)
app.add_config_value( app.add_config_value(
'doctest_default_flags', 'doctest_default_flags',
doctest.DONT_ACCEPT_TRUE_FOR_1 | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL, # type: ignore # NOQA doctest.DONT_ACCEPT_TRUE_FOR_1 | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL,
False) False)
return {'version': sphinx.__display_version__, 'parallel_read_safe': True} return {'version': sphinx.__display_version__, 'parallel_read_safe': True}

View File

@ -69,7 +69,7 @@ class XRefRole(object):
* Subclassing and overwriting `process_link()` and/or `result_nodes()`. * Subclassing and overwriting `process_link()` and/or `result_nodes()`.
""" """
nodeclass = addnodes.pending_xref nodeclass = addnodes.pending_xref # type: Type[nodes.Node]
innernodeclass = nodes.literal innernodeclass = nodes.literal
def __init__(self, fix_parens=False, lowercase=False, def __init__(self, fix_parens=False, lowercase=False,