Fix typing.Union check on Python 3.5.2

Apparently 3.5.4 has __origin__ for typing.Union, but 3.5.2 has not. Let's hope
this now works everywhere...
This commit is contained in:
Florian Bruhin 2018-02-10 21:27:40 +01:00
parent 52d7ff79fc
commit a472351423

View File

@ -394,7 +394,9 @@ class Command:
if isinstance(typ, tuple):
raise TypeError("{}: Legacy tuple type annotation!".format(
self.name))
elif getattr(typ, '__origin__', None) is typing.Union:
elif getattr(typ, '__origin__', None) is typing.Union or (
hasattr(typing, 'UnionMeta') and
isinstance(typ, typing.UnionMeta)):
# this is... slightly evil, I know
# pylint: disable=no-member,useless-suppression
try: