Repository: Rapptz/discord.py
File: discord/ui/select.py (Python)

Code before:
        ComponentType.channel_select: (GuildChannel, AppCommandChannel, AppCommandThread, Thread, Object),
        ComponentType.mentionable_select: (User, Member, Role, Object),
    }

    values: List[SelectDefaultValue] = []
    for obj in defaults:
        if isinstance(obj, SelectDefaultValue):
            values.append(obj)
            continue

        object_type = obj.__class__ if not isinstance(obj, Object) else obj.type

        print(object_type, component_type, object_type == Object)

        if object_type not in type_to_supported_classes[component_type]:
            supported_classes = [c.__name__ for c in type_to_supported_classes[component_type]]
            if len(supported_classes) > 2:
                supported_classes = ', '.join(supported_classes[:-1]) + f', or {supported_classes[-1]}'
            elif len(supported_classes) == 2:
                supported_classes = f'{supported_classes[0]} or {supported_classes[1]}'
            else:
                supported_classes = supported_classes[0]

            raise TypeError(f'Expected an instance of {supported_classes} not {object_type.__name__}')

        if object_type == Object:
            if component_type is ComponentType.mentionable_select:
                raise ValueError(
                    'Object must have a type specified for the chosen select type. Please pass one using the `type`` kwarg.'
                )
            elif component_type is ComponentType.user_select:
                object_type = User
            elif component_type is ComponentType.role_select:
                object_type = Role
            elif component_type is ComponentType.channel_select:
                object_type = GuildChannel

        values.append(SelectDefaultValue(id=obj.id, type=cls_to_type[object_type]))

    return values


class BaseSelect(Item[V]):
    """The base Select model that all other Select models inherit from.

    This class inherits from :class:`Item` and implements the common attributes.

    The following implement this class:

    - :class:`~discord.ui.Select`
    - :class:`~discord.ui.ChannelSelect`

Review comment (suggestion):
```suggestion
        if object_type is Object:
```

Code after:
            continue

        object_type = obj.__class__ if not isinstance(obj, Object) else obj.type

        if object_type not in type_to_supported_classes[component_type]:
            # TODO: split this into a util function
            supported_classes = [c.__name__ for c in type_to_supported_classes[component_type]]
            if len(supported_classes) > 2:
                supported_classes = ', '.join(supported_classes[:-1]) + f', or {supported_classes[-1]}'
            elif len(supported_classes) == 2:
                supported_classes = f'{supported_classes[0]} or {supported_classes[1]}'
            else:
                supported_classes = supported_classes[0]

            raise TypeError(f'Expected an instance of {supported_classes} not {object_type.__name__}')

        if object_type is Object:
            if component_type is ComponentType.mentionable_select:
                raise ValueError(
                    'Object must have a type specified for the chosen select type. Please pass one using the `type`` kwarg.'
                )
            elif component_type is ComponentType.user_select:
                object_type = User
            elif component_type is ComponentType.role_select:
                object_type = Role
            elif component_type is ComponentType.channel_select:
                object_type = GuildChannel

        values.append(SelectDefaultValue(id=obj.id, type=cls_to_type[object_type]))

    return values


class BaseSelect(Item[V]):
    """The base Select model that all other Select models inherit from.

    This class inherits from :class:`Item` and implements the common attributes.

    The following implement this class:

    - :class:`~discord.ui.Select`
    - :class:`~discord.ui.ChannelSelect`
    - :class:`~discord.ui.RoleSelect`
    - :class:`~discord.ui.MentionableSelect`
    - :class:`~discord.ui.UserSelect`

    .. versionadded:: 2.1

    Attributes
    ------------
    row: Optional[:class:`int`]