Skip to content

Commit 23c2632

Browse files
committed
♻️ InteractionXyz -> PartialXyz
1 parent 8d0fa2a commit 23c2632

File tree

8 files changed

+188
-194
lines changed

8 files changed

+188
-194
lines changed

discord/components/__init__.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,27 @@
3232
from .default_select_option import DefaultSelectOption
3333
from .file_component import FileComponent
3434
from .input_text import TextInput
35-
from .interaction_components import (
36-
InteractionButton,
37-
InteractionChannelSelect,
38-
InteractionComponent,
39-
InteractionLabel,
40-
InteractionMentionableSelect,
41-
InteractionRoleSelect,
42-
InteractionSelect,
43-
InteractionStringSelect,
44-
InteractionTextDisplay,
45-
InteractionTextInput,
46-
InteractionUserSelect,
47-
InteractionWalkableComponent,
48-
UnknownInteractionComponent,
49-
_interaction_component_factory, # pyright: ignore[reportPrivateUsage]
50-
)
5135
from .label import Label
5236
from .media_gallery import MediaGallery
5337
from .media_gallery_item import MediaGalleryItem
5438
from .mentionable_select_menu import MentionableSelect
5539
from .modal import Modal
40+
from .partial_components import (
41+
PartialButton,
42+
PartialChannelSelect,
43+
PartialComponent,
44+
PartialLabel,
45+
PartialMentionableSelect,
46+
PartialRoleSelect,
47+
PartialSelect,
48+
PartialStringSelect,
49+
PartialTextDisplay,
50+
PartialTextInput,
51+
PartialUserSelect,
52+
PartialWalkableComponent,
53+
UnknownPartialComponent,
54+
_interaction_component_factory, # pyright: ignore[reportPrivateUsage]
55+
)
5656
from .role_select_menu import RoleSelect
5757
from .section import Section
5858
from .select_menu import Select
@@ -65,11 +65,11 @@
6565
# Don't change the import order
6666
from .type_aliases import (
6767
AnyComponent,
68-
AnyInteractionComponent,
69-
AnyMessageInteractionComponent,
68+
AnyMessagePartialComponent,
69+
AnyPartialComponent,
7070
AnyTopLevelMessageComponent,
7171
AnyTopLevelModalComponent,
72-
AnyTopLevelModalInteractionComponent,
72+
AnyTopLevelModalPartialComponent,
7373
)
7474
from .unfurled_media_item import UnfurledMediaItem
7575
from .unknown_component import UnknownComponent
@@ -89,7 +89,7 @@
8989
"RoleSelect",
9090
"MentionableSelect",
9191
"ChannelSelect",
92-
"AnyMessageInteractionComponent",
92+
"AnyMessagePartialComponent",
9393
"SelectOption",
9494
"DefaultSelectOption",
9595
"TextInput",
@@ -106,23 +106,23 @@
106106
"Modal",
107107
"UnknownComponent",
108108
"_component_factory",
109-
"InteractionLabel",
110-
"InteractionComponent",
111-
"InteractionSelect",
112-
"InteractionStringSelect",
113-
"InteractionUserSelect",
114-
"InteractionButton",
115-
"InteractionRoleSelect",
116-
"InteractionMentionableSelect",
117-
"InteractionChannelSelect",
118-
"InteractionTextInput",
119-
"InteractionTextDisplay",
120-
"UnknownInteractionComponent",
109+
"PartialLabel",
110+
"PartialComponent",
111+
"PartialSelect",
112+
"PartialStringSelect",
113+
"PartialUserSelect",
114+
"PartialButton",
115+
"PartialRoleSelect",
116+
"PartialMentionableSelect",
117+
"PartialChannelSelect",
118+
"PartialTextInput",
119+
"PartialTextDisplay",
120+
"UnknownPartialComponent",
121121
"_interaction_component_factory",
122122
"AnyComponent",
123123
"AnyTopLevelModalComponent",
124124
"AnyTopLevelMessageComponent",
125-
"AnyInteractionComponent",
126-
"AnyTopLevelModalInteractionComponent",
127-
"InteractionWalkableComponent",
125+
"AnyPartialComponent",
126+
"AnyTopLevelModalPartialComponent",
127+
"PartialWalkableComponent",
128128
)

discord/components/components_holder.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from typing_extensions import TypeVarTuple, Unpack, override
66

77
from .component import Component, WalkableComponent
8-
from .interaction_components import InteractionComponent, InteractionWalkableComponent
9-
from .type_aliases import AnyComponent, AnyInteractionComponent
8+
from .partial_components import PartialComponent, PartialWalkableComponent
9+
from .type_aliases import AnyComponent, AnyPartialComponent
1010

1111
Ts = TypeVarTuple(
12-
"Ts", default=Unpack[tuple[AnyComponent | AnyInteractionComponent]]
12+
"Ts", default=Unpack[tuple[AnyComponent | AnyPartialComponent]]
1313
) # Unforntunately, we cannot use `TypeVarTuple` with upper bounds yet.
1414

1515

@@ -26,18 +26,18 @@ class ComponentsHolder(tuple[Unpack[Ts]], Generic[Unpack[Ts]]):
2626
def __new__(cls, *components: Unpack[Ts]) -> ComponentsHolder[Unpack[Ts]]:
2727
return super().__new__(cls, components)
2828

29-
def get_by_id(self, component_id: str | int) -> AnyComponent | AnyInteractionComponent | None:
29+
def get_by_id(self, component_id: str | int) -> AnyComponent | AnyPartialComponent | None:
3030
"""Get a component by its custom ID."""
3131
for maybe_component in self:
32-
if not isinstance(maybe_component, (Component, InteractionComponent)):
33-
raise TypeError(f"Expected {Component} or {InteractionComponent} but got {maybe_component}")
34-
component = cast(AnyComponent | AnyInteractionComponent, maybe_component)
32+
if not isinstance(maybe_component, (Component, PartialComponent)):
33+
raise TypeError(f"Expected {Component} or {PartialComponent} but got {maybe_component}")
34+
component = cast(AnyComponent | AnyPartialComponent, maybe_component)
3535
if isinstance(component_id, str) and getattr(component, "custom_id", None) == component_id:
3636
return component
3737
elif isinstance(component_id, int) and getattr(component, "id", None) == component_id:
3838
return component
3939

40-
if isinstance(component, (WalkableComponent, InteractionWalkableComponent)):
40+
if isinstance(component, (WalkableComponent, PartialWalkableComponent)):
4141
if found := component.get_by_id(component_id):
4242
return found
4343
return None

0 commit comments

Comments
 (0)