def _should_merge(self, pytd_type, union):
    'Determine whether pytd_type values in the union should be merged.\n\n    If the union contains the homogeneous flavor of pytd_type (e.g.,\n    GenericType(base_type=tuple) when pytd_type is TupleType), or pytd_type\n    values of different lengths, we want to turn all of the pytd_type values\n    into homogeneous ones so that they can be merged into a single container.\n\n    Args:\n      pytd_type: The pytd type, either TupleType or CallableType.\n      union: a pytd.UnionType\n\n    Returns:\n      True if the pytd_type values should be merged, False otherwise.\n    '
    names = self._CONTAINER_NAMES[pytd_type]
    length = None
    for t in union.type_list:
        if isinstance(t, pytd_type):
            if (length is None):
                length = len(t.parameters)
            elif (length != len(t.parameters)):
                return True
        elif (isinstance(t, pytd.GenericType) and (t.base_type.name in names)):
            return True
    return False
Determine whether pytd_type values in the union should be merged.

If the union contains the homogeneous flavor of pytd_type (e.g.,
GenericType(base_type=tuple) when pytd_type is TupleType), or pytd_type
values of different lengths, we want to turn all of the pytd_type values
into homogeneous ones so that they can be merged into a single container.

Args:
  pytd_type: The pytd type, either TupleType or CallableType.
  union: a pytd.UnionType

Returns:
  True if the pytd_type values should be merged, False otherwise.
def _should_merge(self, pytd_type, union):
    'Determine whether pytd_type values in the union should be merged.\n\n    If the union contains the homogeneous flavor of pytd_type (e.g.,\n    GenericType(base_type=tuple) when pytd_type is TupleType), or pytd_type\n    values of different lengths, we want to turn all of the pytd_type values\n    into homogeneous ones so that they can be merged into a single container.\n\n    Args:\n      pytd_type: The pytd type, either TupleType or CallableType.\n      union: a pytd.UnionType\n\n    Returns:\n      True if the pytd_type values should be merged, False otherwise.\n    '
    names = self._CONTAINER_NAMES[pytd_type]
    length = None
    for t in union.type_list:
        if isinstance(t, pytd_type):
            if (length is None):
                length = len(t.parameters)
            elif (length != len(t.parameters)):
                return True
        elif (isinstance(t, pytd.GenericType) and (t.base_type.name in names)):
            return True
    return False