mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3135: `sphinx.ext.autodoc` crashes with plain Callable
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -9,6 +9,7 @@ Bugs fixed
|
||||
results in warning / error
|
||||
* #3068: Allow the '=' character in the -D option of sphinx-build.py
|
||||
* #3074: ``add_source_parser()`` crashes in debug mode
|
||||
* #3135: ``sphinx.ext.autodoc`` crashes with plain Callable
|
||||
|
||||
Release 1.4.8 (released Oct 1, 2016)
|
||||
====================================
|
||||
|
||||
@@ -306,7 +306,9 @@ def format_annotation(annotation):
|
||||
hasattr(annotation, '__args__') and \
|
||||
hasattr(annotation, '__result__'):
|
||||
args = annotation.__args__
|
||||
if args is Ellipsis:
|
||||
if args is None:
|
||||
return qualified_name
|
||||
elif args is Ellipsis:
|
||||
args_str = '...'
|
||||
else:
|
||||
formatted_args = (format_annotation(a) for a in args)
|
||||
|
||||
@@ -13,3 +13,4 @@ whoosh>=2.0
|
||||
alabaster
|
||||
sphinx_rtd_theme
|
||||
imagesize
|
||||
typing
|
||||
|
||||
@@ -1025,7 +1025,7 @@ def test_type_hints():
|
||||
from sphinx.util.inspect import getargspec
|
||||
|
||||
try:
|
||||
from typing_test_data import f0, f1, f2, f3, f4, f5, f6, f7, f8, f9
|
||||
from typing_test_data import f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10
|
||||
except (ImportError, SyntaxError):
|
||||
raise SkipTest('Cannot import Python code with function annotations')
|
||||
|
||||
@@ -1057,10 +1057,11 @@ def test_type_hints():
|
||||
|
||||
# Callable types
|
||||
verify_arg_spec(f7, '(x: typing.Callable[[int, str], int]) -> None')
|
||||
verify_arg_spec(f8, '(x: typing.Callable) -> None')
|
||||
|
||||
# Tuple types
|
||||
verify_arg_spec(f8, '(x: typing.Tuple[int, str],'
|
||||
verify_arg_spec(f9, '(x: typing.Tuple[int, str],'
|
||||
' y: typing.Tuple[int, ...]) -> None')
|
||||
|
||||
# Instance annotations
|
||||
verify_arg_spec(f9, '(x: CustomAnnotation, y: 123) -> None')
|
||||
verify_arg_spec(f10, '(x: CustomAnnotation, y: 123) -> None')
|
||||
|
||||
@@ -44,7 +44,11 @@ def f7(x: Callable[[int, str], int]) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def f8(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
|
||||
def f8(x: Callable) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def f9(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@@ -52,5 +56,6 @@ class CustomAnnotation:
|
||||
def __repr__(self):
|
||||
return 'CustomAnnotation'
|
||||
|
||||
def f9(x: CustomAnnotation(), y: 123) -> None:
|
||||
|
||||
def f10(x: CustomAnnotation(), y: 123) -> None:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user