def METHOD_NAME(type_spec):
  """Creates a string representation of `type_spec` for error reporting.
  Args:
    type_spec: Either a Python type, or a tuple of Python types; the same as
      what's accepted by isinstance.
  Returns:
    A string representation for use in error reporting.
  Raises:
    TypeError: if the `type_spec` is not of the right type.
  """
  if isinstance(type_spec, type):
    if type_spec.__module__ == builtins.__name__:
      return type_spec.__name__
    else:
      return '{}.{}'.format(type_spec.__module__, type_spec.__name__)
  else:
    assert isinstance(type_spec, (tuple, list))
    type_names = [METHOD_NAME(x) for x in type_spec]
    if len(type_names) == 1:
      return type_names[0]
    elif len(type_names) == 2:
      return '{} or {}'.format(*type_names)
    else:
      return ', '.join(type_names[0:-1] + ['or {}'.format(type_names[-1])])