Merge pull request #2532 from mitya57/stable

Fix for test failures with Python 3.5.2 snapshot
This commit is contained in:
Takeshi KOMIYA
2016-05-21 11:02:06 +09:00
2 changed files with 12 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ python:
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev"
- "pypy"
env:
global:

View File

@@ -269,8 +269,16 @@ def format_annotation(annotation):
if isinstance(annotation, typing.TypeVar):
return annotation.__name__
elif hasattr(typing, 'GenericMeta') and \
isinstance(annotation, typing.GenericMeta) and \
hasattr(annotation, '__parameters__'):
isinstance(annotation, typing.GenericMeta):
# In Python 3.5.2+, all arguments are stored in __args__,
# whereas __parameters__ only contains generic parameters.
#
# Prior to Python 3.5.2, __args__ is not available, and all
# arguments are in __parameters__.
params = None
if hasattr(annotation, '__args__'):
params = annotation.__args__
elif hasattr(annotation, '__parameters__'):
params = annotation.__parameters__
if params is not None:
param_str = ', '.join(format_annotation(p) for p in params)