code: def is_Union(tp):
      
      if tp is Union:
          return True
      try:
          # Python 3.6
          return tp.__origin__ is Union
      except AttributeError:
          try:
              return isinstance(tp, typing.UnionMeta)
          except AttributeError:
              return False
docs: Python version independent check if a type is typing.Union.
      Tested with CPython 2.7, 3.5, 3.6 and Jython 2.7.1.