diff --git a/discord/ui/action_row.py b/discord/ui/action_row.py index dfb93878d..5cc41de26 100644 --- a/discord/ui/action_row.py +++ b/discord/ui/action_row.py @@ -87,10 +87,10 @@ class _ActionRowCallback: class ActionRow(Item[V]): - """Represents a UI action row. + r"""Represents a UI action row. This is a top-level layout component that can only be used on :class:`LayoutView` - and can contain :class:`Button` 's and :class:`Select` 's in it. + and can contain :class:`Button`\s and :class:`Select`\s in it. This can be inherited. diff --git a/discord/ui/container.py b/discord/ui/container.py index 77dee7fa4..8c550816f 100644 --- a/discord/ui/container.py +++ b/discord/ui/container.py @@ -73,11 +73,11 @@ class _ContainerCallback: class Container(Item[V]): - """Represents a UI container. + r"""Represents a UI container. This is a top-level layout component that can only be used on :class:`LayoutView` - and can contain :class:`ActionRow` 's, :class:`TextDisplay` 's, :class:`Section` 's, - :class:`MediaGallery` 's, and :class:`File` 's in it. + and can contain :class:`ActionRow`\s, :class:`TextDisplay`\s, :class:`Section`\s, + :class:`MediaGallery`\s, and :class:`File`\s in it. This can be inherited. diff --git a/discord/ui/dynamic.py b/discord/ui/dynamic.py index 667848920..3c7ea0e48 100644 --- a/discord/ui/dynamic.py +++ b/discord/ui/dynamic.py @@ -38,14 +38,10 @@ if TYPE_CHECKING: from ..interactions import Interaction from ..components import Component from ..enums import ComponentType - from .view import BaseView + from .view import View, LayoutView - V = TypeVar('V', bound='BaseView', covariant=True, default=BaseView) -else: - V = TypeVar('V', bound='BaseView', covariant=True) - -class DynamicItem(Generic[BaseT, V], Item[V]): +class DynamicItem(Generic[BaseT], Item[Union[View, LayoutView]]): """Represents an item with a dynamic ``custom_id`` that can be used to store state within that ``custom_id``. diff --git a/discord/ui/media_gallery.py b/discord/ui/media_gallery.py index e7346bf69..8cfbfa1e3 100644 --- a/discord/ui/media_gallery.py +++ b/discord/ui/media_gallery.py @@ -44,9 +44,9 @@ __all__ = ('MediaGallery',) class MediaGallery(Item[V]): - """Represents a UI media gallery. + r"""Represents a UI media gallery. - Can contain up to 10 :class:`.MediaGalleryItem` 's. + Can contain up to 10 :class:`.MediaGalleryItem`\s. This is a top-level layout component that can only be used on :class:`LayoutView`. diff --git a/discord/ui/view.py b/discord/ui/view.py index 4a7afa50c..533339b84 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -575,7 +575,7 @@ class BaseView: self._total_children = 0 return self - def get_item_by_id(self, id: int, /) -> Optional[Item[Self]]: + def get_item(self, id: int, /) -> Optional[Item[Self]]: """Gets an item with :attr:`Item.id` set as ``id``, or ``None`` if not found.