Skip to content

Commit 0286c68

Browse files
committed
Merge pull request #2532 from mitya57/stable
Fix for test failures with Python 3.5.2 snapshot
2 parents 8ca9d55 + b412a9c commit 0286c68

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python:
99
- "3.3"
1010
- "3.4"
1111
- "3.5"
12+
- "3.5-dev"
1213
- "pypy"
1314
env:
1415
global:

sphinx/ext/autodoc.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,17 @@ def format_annotation(annotation):
269269
if isinstance(annotation, typing.TypeVar):
270270
return annotation.__name__
271271
elif hasattr(typing, 'GenericMeta') and \
272-
isinstance(annotation, typing.GenericMeta) and \
273-
hasattr(annotation, '__parameters__'):
274-
params = annotation.__parameters__
272+
isinstance(annotation, typing.GenericMeta):
273+
# In Python 3.5.2+, all arguments are stored in __args__,
274+
# whereas __parameters__ only contains generic parameters.
275+
#
276+
# Prior to Python 3.5.2, __args__ is not available, and all
277+
# arguments are in __parameters__.
278+
params = None
279+
if hasattr(annotation, '__args__'):
280+
params = annotation.__args__
281+
elif hasattr(annotation, '__parameters__'):
282+
params = annotation.__parameters__
275283
if params is not None:
276284
param_str = ', '.join(format_annotation(p) for p in params)
277285
return '%s[%s]' % (qualified_name, param_str)

0 commit comments

Comments
 (0)