Browse Source

chore: typings

pull/10166/head
DA-344 3 months ago
parent
commit
e9d942b233
  1. 2
      discord/ui/container.py
  2. 4
      discord/ui/dynamic.py
  3. 8
      discord/ui/view.py

2
discord/ui/container.py

@ -224,7 +224,7 @@ class Container(Item[V]):
pattern = item.__discord_ui_compiled_template__
dynamic_items[pattern] = item.__class__
elif item.is_dispatchable():
dispatch_info[(item.type.value, item.custom_id)] = item # type: ignore
dispatch_info[(item.type.value, item.custom_id)] = item
is_fully_dynamic = False
return is_fully_dynamic

4
discord/ui/dynamic.py

@ -144,7 +144,7 @@ class DynamicItem(Generic[BaseT], Item['BaseView']):
@property
def custom_id(self) -> str:
""":class:`str`: The ID of the dynamic item that gets received during an interaction."""
return self.item.custom_id # type: ignore # This attribute exists for dispatchable items
return self.item.custom_id
@custom_id.setter
def custom_id(self, value: str) -> None:
@ -154,7 +154,7 @@ class DynamicItem(Generic[BaseT], Item['BaseView']):
if not self.template.match(value):
raise ValueError(f'custom_id must match the template {self.template.pattern!r}')
self.item.custom_id = value # type: ignore # This attribute exists for dispatchable items
self.item.custom_id = value
self._provided_custom_id = True
@property

8
discord/ui/view.py

@ -492,7 +492,7 @@ class BaseView:
def _refresh(self, components: List[Component]) -> None:
# fmt: off
old_state: Dict[str, Item[Any]] = {
item.custom_id: item # type: ignore
item.custom_id: item
for item in self._children
if item.is_dispatchable()
}
@ -859,9 +859,9 @@ class ViewStore:
pattern = accessory.__discord_ui_compiled_template__
self._dynamic_items[pattern] = accessory.__class__
else:
dispatch_info[(accessory.type.value, accessory.custom_id)] = accessory # type: ignore
dispatch_info[(accessory.type.value, accessory.custom_id)] = accessory
else:
dispatch_info[(item.type.value, item.custom_id)] = item # type: ignore
dispatch_info[(item.type.value, item.custom_id)] = item
is_fully_dynamic = False
view._cache_key = message_id
@ -880,7 +880,7 @@ class ViewStore:
pattern = item.__discord_ui_compiled_template__
self._dynamic_items.pop(pattern, None)
elif item.is_dispatchable():
dispatch_info.pop((item.type.value, item.custom_id), None) # type: ignore
dispatch_info.pop((item.type.value, item.custom_id), None)
if len(dispatch_info) == 0:
self._views.pop(view._cache_key, None)

Loading…
Cancel
Save