Reintroduce handling for typing.Union.__union_params__

Looks like Python 3.5.2 doesn't have typing.Union.__args__.
This commit is contained in:
Florian Bruhin 2017-09-20 07:41:47 +02:00
parent a519d54e7d
commit ba1cf06be6

View File

@ -405,7 +405,11 @@ class Command:
# We also can't use isinstance here because typing.Union doesn't
# support that.
# pylint: disable=no-member,useless-suppression
types = list(typ.__args__)
try:
types = list(typ.__args__)
except AttributeError:
# Older Python 3.5 patch versions
types = list(typ.__union_params__)
# pylint: enable=no-member,useless-suppression
if param.default is not inspect.Parameter.empty:
types.append(type(param.default))