Merge branch '1.7' into 1042_strip_parens

This commit is contained in:
Takeshi KOMIYA 2018-03-04 02:10:31 +09:00 committed by GitHub
commit b707ab35e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -18,6 +18,7 @@ Bugs fixed
* #4669: sphinx.build_main and sphinx.make_main throw NameError * #4669: sphinx.build_main and sphinx.make_main throw NameError
* #4685: autosummary emits meaningless warnings * #4685: autosummary emits meaningless warnings
* autodoc: crashed when invalid options given
* pydomain: always strip parenthesis if empty (refs: #1042) * pydomain: always strip parenthesis if empty (refs: #1042)
Testing Testing

View File

@ -58,7 +58,7 @@ class DocumenterBridge(object):
def warn(self, msg): def warn(self, msg):
# type: (unicode) -> None # type: (unicode) -> None
logger.warning(msg, line=self.lineno) logger.warning(msg, location=(self.env.docname, self.lineno))
def process_documenter_options(documenter, config, options): def process_documenter_options(documenter, config, options):
@ -125,7 +125,7 @@ class AutodocDirective(Directive):
except (KeyError, ValueError, TypeError) as exc: except (KeyError, ValueError, TypeError) as exc:
# an option is either unknown or has a wrong type # an option is either unknown or has a wrong type
logger.error('An option to %s is either unknown or has an invalid value: %s' % logger.error('An option to %s is either unknown or has an invalid value: %s' %
(self.name, exc), line=lineno) (self.name, exc), location=(source, lineno))
return [] return []
# generate the output # generate the output

View File

@ -114,7 +114,7 @@ else: # 2.7
func = func.func func = func.func
if not inspect.isfunction(func): if not inspect.isfunction(func):
raise TypeError('%r is not a Python function' % func) raise TypeError('%r is not a Python function' % func)
args, varargs, varkw = inspect.getargs(func.__code__) # type: ignore args, varargs, varkw = inspect.getargs(func.__code__)
func_defaults = func.__defaults__ func_defaults = func.__defaults__
if func_defaults is None: if func_defaults is None:
func_defaults = [] func_defaults = []
@ -124,13 +124,13 @@ else: # 2.7
args = args[parts[0]:] args = args[parts[0]:]
if parts[1]: if parts[1]:
for arg in parts[1]: for arg in parts[1]:
i = args.index(arg) - len(args) i = args.index(arg) - len(args) # type: ignore
del args[i] del args[i]
try: try:
del func_defaults[i] del func_defaults[i]
except IndexError: except IndexError:
pass pass
return inspect.ArgSpec(args, varargs, varkw, func_defaults) return inspect.ArgSpec(args, varargs, varkw, func_defaults) # type: ignore
try: try:
import enum import enum