Skip to content

Commit 480750d

Browse files
committed
Add sensible defaults and new types
1 parent 5c06728 commit 480750d

File tree

3 files changed

+87
-98
lines changed

3 files changed

+87
-98
lines changed

hikari/api/special_endpoints.py

+34-35
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
"MediaGalleryComponentBuilder",
5252
"MediaGalleryItemBuilder",
5353
"SeparatorComponentBuilder",
54-
"MessageFileBuilder",
55-
"MessageContainerBuilder",
56-
"MessageContainerBuilderComponentsT",
54+
"FileComponentBuilder",
55+
"ContainerComponentBuilder",
56+
"ContainerBuilderComponentsT",
5757
"ModalActionRowBuilder",
5858
)
5959

@@ -2271,11 +2271,11 @@ def type(self) -> typing.Literal[components_.ComponentType.ACTION_ROW]:
22712271

22722272
@property
22732273
@abc.abstractmethod
2274-
def components(self) -> typing.Sequence[ComponentBuilder]:
2274+
def components(self) -> typing.Sequence[ModalActionRowBuilderComponentsT]:
22752275
"""Sequence of the component builders registered within this action row."""
22762276

22772277
@abc.abstractmethod
2278-
def add_component(self, component: ComponentBuilder, /) -> Self:
2278+
def add_component(self, component: ModalActionRowBuilderComponentsT, /) -> Self:
22792279
"""Add a component to this action row builder.
22802280
22812281
!!! warning
@@ -2356,9 +2356,10 @@ def type(self) -> typing.Literal[components_.ComponentType.SECTION]:
23562356
def components(self) -> typing.Sequence[TextDisplayComponentBuilder]:
23572357
"""The components attached to the section."""
23582358

2359+
# FIXME: Extract the return type union
23592360
@property
23602361
@abc.abstractmethod
2361-
def accessory(self) -> typing.Union[InteractiveButtonBuilder, LinkButtonBuilder, ThumbnailComponentBuilder]:
2362+
def accessory(self) -> typing.Union[ButtonBuilder, ThumbnailComponentBuilder]:
23622363
"""The accessory attached to the section."""
23632364

23642365
@abc.abstractmethod
@@ -2439,8 +2440,8 @@ def description(self) -> undefined.UndefinedOr[str]:
24392440

24402441
@property
24412442
@abc.abstractmethod
2442-
def spoiler(self) -> undefined.UndefinedOr[bool]:
2443-
"""Whether the media has a spoiler."""
2443+
def is_spoiler(self) -> bool:
2444+
"""Whether the media is marked as a spoiler."""
24442445

24452446

24462447
class MediaGalleryComponentBuilder(ComponentBuilder, abc.ABC):
@@ -2484,7 +2485,7 @@ def add_media_gallery_item(
24842485
media: files.Resourceish,
24852486
*,
24862487
description: undefined.UndefinedOr[str] = undefined.UNDEFINED,
2487-
spoiler: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
2488+
spoiler: bool = False,
24882489
) -> Self:
24892490
"""Add a media gallery item component to this media gallery builder.
24902491
@@ -2521,8 +2522,8 @@ def description(self) -> undefined.UndefinedOr[str]:
25212522

25222523
@property
25232524
@abc.abstractmethod
2524-
def spoiler(self) -> undefined.UndefinedOr[bool]:
2525-
"""Whether the media has a spoiler."""
2525+
def is_spoiler(self) -> bool:
2526+
"""Whether the media is marked as a spoiler."""
25262527

25272528
@abc.abstractmethod
25282529
def build(
@@ -2558,7 +2559,7 @@ def divider(self) -> undefined.UndefinedOr[bool]:
25582559
"""Whether the separator has a divider."""
25592560

25602561

2561-
class MessageFileBuilder(ComponentBuilder, abc.ABC):
2562+
class FileComponentBuilder(ComponentBuilder, abc.ABC):
25622563
"""Builder class for file components."""
25632564

25642565
__slots__: typing.Sequence[str] = ()
@@ -2575,11 +2576,11 @@ def file(self) -> files.Resourceish:
25752576

25762577
@property
25772578
@abc.abstractmethod
2578-
def spoiler(self) -> undefined.UndefinedOr[bool]:
2579+
def is_spoiler(self) -> bool:
25792580
"""Whether the file has a spoiler."""
25802581

25812582

2582-
class MessageContainerBuilder(ComponentBuilder, abc.ABC):
2583+
class ContainerComponentBuilder(ComponentBuilder, abc.ABC):
25832584
"""Builder class for container components."""
25842585

25852586
__slots__: typing.Sequence[str] = ()
@@ -2599,16 +2600,16 @@ def accent_color(self) -> undefined.UndefinedOr[colors.Color]:
25992600

26002601
@property
26012602
@abc.abstractmethod
2602-
def spoiler(self) -> undefined.UndefinedOr[bool]:
2603+
def is_spoiler(self) -> bool:
26032604
"""Whether the container has a spoiler."""
26042605

26052606
@property
26062607
@abc.abstractmethod
2607-
def components(self) -> typing.Sequence[MessageContainerBuilderComponentsT]:
2608+
def components(self) -> typing.Sequence[ContainerBuilderComponentsT]:
26082609
"""The components attached to the container."""
26092610

26102611
@abc.abstractmethod
2611-
def add_component(self, component: MessageContainerBuilderComponentsT) -> Self:
2612+
def add_component(self, component: ContainerBuilderComponentsT) -> Self:
26122613
"""Add a component to this container builder.
26132614
26142615
!!! warning
@@ -2627,7 +2628,7 @@ def add_component(self, component: MessageContainerBuilderComponentsT) -> Self:
26272628
26282629
Returns
26292630
-------
2630-
MessageContainerBuilder
2631+
ContainerComponentBuilder
26312632
The builder object to enable chained calls.
26322633
"""
26332634

@@ -2651,7 +2652,7 @@ def add_action_row(
26512652
26522653
Returns
26532654
-------
2654-
MessageContainerBuilder
2655+
ContainerComponentBuilder
26552656
The builder object to enable chained calls.
26562657
"""
26572658

@@ -2670,7 +2671,7 @@ def add_text_display(self, content: str, *, id: undefined.UndefinedOr[int] = und
26702671
26712672
Returns
26722673
-------
2673-
MessageContainerBuilder
2674+
ContainerComponentBuilder
26742675
The builder object to enable chained calls.
26752676
"""
26762677

@@ -2691,16 +2692,16 @@ def add_media_gallery(
26912692
26922693
Returns
26932694
-------
2694-
MessageContainerBuilder
2695+
ContainerComponentBuilder
26952696
The builder object to enable chained calls.
26962697
"""
26972698

26982699
@abc.abstractmethod
26992700
def add_separator(
27002701
self,
27012702
*,
2702-
spacing: undefined.UndefinedOr[components_.SpacingType] = undefined.UNDEFINED,
2703-
divider: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
2703+
spacing: components_.SpacingType = components_.SpacingType.SMALL,
2704+
divider: bool = False,
27042705
id: undefined.UndefinedOr[int] = undefined.UNDEFINED,
27052706
) -> Self:
27062707
"""Add a separator component to this container builder.
@@ -2718,17 +2719,13 @@ def add_separator(
27182719
27192720
Returns
27202721
-------
2721-
MessageContainerBuilder
2722+
ContainerComponentBuilder
27222723
The builder object to enable chained calls.
27232724
"""
27242725

27252726
@abc.abstractmethod
27262727
def add_file(
2727-
self,
2728-
file: files.Resourceish,
2729-
*,
2730-
spoiler: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
2731-
id: undefined.UndefinedOr[int] = undefined.UNDEFINED,
2728+
self, file: files.Resourceish, *, spoiler: bool = False, id: undefined.UndefinedOr[int] = undefined.UNDEFINED
27322729
) -> Self:
27332730
"""Add a spoiler component to this container builder.
27342731
@@ -2745,23 +2742,25 @@ def add_file(
27452742
27462743
Returns
27472744
-------
2748-
MessageContainerBuilder
2745+
ContainerComponentBuilder
27492746
The builder object to enable chained calls.
27502747
"""
27512748

27522749

2753-
MessageContainerBuilderComponentsT = typing.Union[ # FIXME: I got no idea where this should be put.
2750+
ContainerBuilderComponentsT = typing.Union[
27542751
MessageActionRowBuilder,
27552752
TextDisplayComponentBuilder,
27562753
SectionComponentBuilder,
27572754
MediaGalleryComponentBuilder,
27582755
SeparatorComponentBuilder,
2759-
MessageFileBuilder,
2756+
FileComponentBuilder,
27602757
]
27612758
"""FIXME: Document me."""
27622759

27632760

2764-
MessageActionRowBuilderComponentsT = typing.Union[ # FIXME: I got no idea where this should be put.
2765-
ButtonBuilder, SelectMenuBuilder
2766-
]
2761+
MessageActionRowBuilderComponentsT = typing.Union[ButtonBuilder, SelectMenuBuilder]
27672762
"""FIXME: Document me."""
2763+
2764+
ModalActionRowBuilderComponentsT = TextInputBuilder
2765+
""""FIXME: Document me."""
2766+
# FIXME: Add ModalActionRowBuilderComponentsT

0 commit comments

Comments
 (0)