File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 99 - " 3.3"
1010 - " 3.4"
1111 - " 3.5"
12+ - " 3.5-dev"
1213 - " pypy"
1314env :
1415 global :
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments