def VisitUnionType(self, union):
    'Given a union type, try to find a simplification by using superclasses.\n\n    This is a lossy optimization that tries to map a list of types to a common\n    base type. For example, int and bool are both base classes of int, so it\n    would convert "int or bool" to "int".\n\n    Arguments:\n      union: A union type.\n\n    Returns:\n      A simplified type, if available.\n    '
    intersection = self.hierarchy.ExpandSuperClasses(str(union.type_list[0]))
    for t in union.type_list[1:]:
        intersection.intersection_update(self.hierarchy.ExpandSuperClasses(str(t)))
    new_type_list = tuple((pytd.NamedType(cls) for cls in intersection if (not self.hierarchy.HasSubClassInSet(cls, intersection))))
    if (not new_type_list):
        return union
    return pytd_utils.JoinTypes(new_type_list)
Given a union type, try to find a simplification by using superclasses.

This is a lossy optimization that tries to map a list of types to a common
base type. For example, int and bool are both base classes of int, so it
would convert "int or bool" to "int".

Arguments:
  union: A union type.

Returns:
  A simplified type, if available.
def VisitUnionType(self, union):
    'Given a union type, try to find a simplification by using superclasses.\n\n    This is a lossy optimization that tries to map a list of types to a common\n    base type. For example, int and bool are both base classes of int, so it\n    would convert "int or bool" to "int".\n\n    Arguments:\n      union: A union type.\n\n    Returns:\n      A simplified type, if available.\n    '
    intersection = self.hierarchy.ExpandSuperClasses(str(union.type_list[0]))
    for t in union.type_list[1:]:
        intersection.intersection_update(self.hierarchy.ExpandSuperClasses(str(t)))
    new_type_list = tuple((pytd.NamedType(cls) for cls in intersection if (not self.hierarchy.HasSubClassInSet(cls, intersection))))
    if (not new_type_list):
        return union
    return pytd_utils.JoinTypes(new_type_list)