Skip to content

Commit e133f84

Browse files
authored
Merge pull request #966 from krittick/modal-typing-fix
Update `Item` references in modal.py to `InputText`
2 parents 97b33db + 0198f43 commit e133f84

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

discord/ui/modal.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
from itertools import groupby
55
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
66

7-
from .item import Item
7+
from .input_text import InputText
88
from .view import _ViewWeights
99

10-
__all__ = ("Modal",)
10+
__all__ = (
11+
"Modal",
12+
"ModalStore",
13+
)
1114

1215

1316
if TYPE_CHECKING:
@@ -24,7 +27,7 @@ class Modal:
2427
def __init__(self, title: str, custom_id: Optional[str] = None) -> None:
2528
self.custom_id = custom_id or os.urandom(16).hex()
2629
self.title = title
27-
self.children: List[Item] = []
30+
self.children: List[InputText] = []
2831
self.__weights = _ViewWeights(self.children)
2932

3033
async def callback(self, interaction: Interaction):
@@ -40,7 +43,7 @@ async def callback(self, interaction: Interaction):
4043
pass
4144

4245
def to_components(self) -> List[Dict[str, Any]]:
43-
def key(item: Item) -> int:
46+
def key(item: InputText) -> int:
4447
return item._rendered_row or 0
4548

4649
children = sorted(self.children, key=key)
@@ -59,30 +62,30 @@ def key(item: Item) -> int:
5962

6063
return components
6164

62-
def add_item(self, item: Item):
63-
"""Adds an item to the modal dialog.
65+
def add_item(self, item: InputText):
66+
"""Adds an InputText component to the modal dialog.
6467
6568
Parameters
6669
----------
67-
item: :class:`Item`
70+
item: :class:`InputText`
6871
The item to add to the modal dialog
6972
"""
7073

7174
if len(self.children) > 5:
7275
raise ValueError("You can only have up to 5 items in a modal dialog.")
7376

74-
if not isinstance(item, Item):
75-
raise TypeError(f"expected Item not {item.__class__!r}")
77+
if not isinstance(item, InputText):
78+
raise TypeError(f"expected InputText not {item.__class__!r}")
7679

7780
self.__weights.add_item(item)
7881
self.children.append(item)
7982

80-
def remove_item(self, item: Item):
81-
"""Removes an item from the modal dialog.
83+
def remove_item(self, item: InputText):
84+
"""Removes an InputText component from the modal dialog.
8285
8386
Parameters
8487
----------
85-
item: :class:`Item`
88+
item: :class:`InputText`
8689
The item to remove from the modal dialog.
8790
"""
8891
try:

0 commit comments

Comments
 (0)