Skip to content

Commit

Permalink
Fix messages argument typing for delete_messages API (#1581)
Browse files Browse the repository at this point in the history
  • Loading branch information
davfsa authored May 8, 2023
1 parent b6cf8ed commit ca4193c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions changes/1581.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `messages` argument typing for `RESTClient.delete_messages`.
9 changes: 5 additions & 4 deletions hikari/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,8 @@ async def delete_messages(
channel: snowflakes.SnowflakeishOr[channels_.TextableChannel],
messages: typing.Union[
snowflakes.SnowflakeishOr[messages_.PartialMessage],
snowflakes.SnowflakeishIterable[messages_.PartialMessage],
typing.Iterable[snowflakes.SnowflakeishOr[messages_.PartialMessage]],
typing.AsyncIterable[snowflakes.SnowflakeishOr[messages_.PartialMessage]],
],
/,
*other_messages: snowflakes.SnowflakeishOr[messages_.PartialMessage],
Expand Down Expand Up @@ -1455,9 +1456,9 @@ async def delete_messages(
channel : hikari.snowflakes.SnowflakeishOr[hikari.channels.TextableChannel]
The channel to bulk delete the messages in. This may be
the object or the ID of an existing channel.
messages : typing.Union[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage], hikari.snowflakes.SnowflakeishIterable[hikari.messages.PartialMessage]]
messages
Either the object/ID of an existing message to delete or an iterable
of the objects and/or IDs of existing messages to delete.
(sync or async) of the objects and/or IDs of existing messages to delete.
Other Parameters
----------------
Expand All @@ -1471,7 +1472,7 @@ async def delete_messages(
messages that were not removed. The
`BaseException.__cause__` of the exception will be the
original error that terminated this process.
""" # noqa: E501 - Line too long
"""

@abc.abstractmethod
async def add_reaction(
Expand Down
30 changes: 16 additions & 14 deletions hikari/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
from hikari import files
from hikari import guilds
from hikari import iterators
from hikari import messages
from hikari import messages as messages_
from hikari import stickers as stickers_
from hikari import users
from hikari import voices
Expand Down Expand Up @@ -409,7 +409,7 @@ def fetch_history(
before: undefined.UndefinedOr[snowflakes.SearchableSnowflakeishOr[snowflakes.Unique]] = undefined.UNDEFINED,
after: undefined.UndefinedOr[snowflakes.SearchableSnowflakeishOr[snowflakes.Unique]] = undefined.UNDEFINED,
around: undefined.UndefinedOr[snowflakes.SearchableSnowflakeishOr[snowflakes.Unique]] = undefined.UNDEFINED,
) -> iterators.LazyIterator[messages.Message]:
) -> iterators.LazyIterator[messages_.Message]:
"""Browse the message history for a given text channel.
.. note::
Expand Down Expand Up @@ -457,7 +457,7 @@ def fetch_history(
"""
return self.app.rest.fetch_messages(self.id, before=before, after=after, around=around)

async def fetch_message(self, message: snowflakes.SnowflakeishOr[messages.PartialMessage]) -> messages.Message:
async def fetch_message(self, message: snowflakes.SnowflakeishOr[messages_.PartialMessage]) -> messages_.Message:
"""Fetch a specific message in the given text channel.
Parameters
Expand Down Expand Up @@ -503,7 +503,7 @@ async def send(
snowflakes.SnowflakeishSequence[stickers_.PartialSticker]
] = undefined.UNDEFINED,
tts: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
reply: undefined.UndefinedOr[snowflakes.SnowflakeishOr[messages.PartialMessage]] = undefined.UNDEFINED,
reply: undefined.UndefinedOr[snowflakes.SnowflakeishOr[messages_.PartialMessage]] = undefined.UNDEFINED,
reply_must_exist: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
mentions_everyone: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
mentions_reply: undefined.UndefinedOr[bool] = undefined.UNDEFINED,
Expand All @@ -513,8 +513,8 @@ async def send(
role_mentions: undefined.UndefinedOr[
typing.Union[snowflakes.SnowflakeishSequence[guilds.PartialRole], bool]
] = undefined.UNDEFINED,
flags: typing.Union[undefined.UndefinedType, int, messages.MessageFlag] = undefined.UNDEFINED,
) -> messages.Message:
flags: typing.Union[undefined.UndefinedType, int, messages_.MessageFlag] = undefined.UNDEFINED,
) -> messages_.Message:
"""Create a message in this channel.
Parameters
Expand Down Expand Up @@ -699,7 +699,7 @@ def trigger_typing(self) -> special_endpoints.TypingIndicator:
"""
return self.app.rest.trigger_typing(self.id)

async def fetch_pins(self) -> typing.Sequence[messages.Message]:
async def fetch_pins(self) -> typing.Sequence[messages_.Message]:
"""Fetch the pinned messages in this text channel.
Returns
Expand All @@ -723,7 +723,7 @@ async def fetch_pins(self) -> typing.Sequence[messages.Message]:
"""
return await self.app.rest.fetch_pins(self.id)

async def pin_message(self, message: snowflakes.SnowflakeishOr[messages.PartialMessage]) -> None:
async def pin_message(self, message: snowflakes.SnowflakeishOr[messages_.PartialMessage]) -> None:
"""Pin an existing message in the text channel.
Parameters
Expand All @@ -749,7 +749,7 @@ async def pin_message(self, message: snowflakes.SnowflakeishOr[messages.PartialM
"""
return await self.app.rest.pin_message(self.id, message)

async def unpin_message(self, message: snowflakes.SnowflakeishOr[messages.PartialMessage]) -> None:
async def unpin_message(self, message: snowflakes.SnowflakeishOr[messages_.PartialMessage]) -> None:
"""Unpin a given message from the text channel.
Parameters
Expand Down Expand Up @@ -778,10 +778,12 @@ async def unpin_message(self, message: snowflakes.SnowflakeishOr[messages.Partia
async def delete_messages(
self,
messages: typing.Union[
snowflakes.SnowflakeishOr[messages.PartialMessage], snowflakes.SnowflakeishIterable[messages.PartialMessage]
snowflakes.SnowflakeishOr[messages_.PartialMessage],
typing.Iterable[snowflakes.SnowflakeishOr[messages_.PartialMessage]],
typing.AsyncIterable[snowflakes.SnowflakeishOr[messages_.PartialMessage]],
],
/,
*other_messages: snowflakes.SnowflakeishOr[messages.PartialMessage],
*other_messages: snowflakes.SnowflakeishOr[messages_.PartialMessage],
) -> None:
"""Bulk-delete messages from the channel.
Expand All @@ -808,9 +810,9 @@ async def delete_messages(
Parameters
----------
messages : typing.Union[hikari.snowflakes.SnowflakeishOr[hikari.messages.PartialMessage], hikari.snowflakes.SnowflakeishIterable[hikari.messages.PartialMessage]]
messages
Either the object/ID of an existing message to delete or an iterable
of the objects and/or IDs of existing messages to delete.
(sync or async) of the objects and/or IDs of existing messages to delete.
Other Parameters
----------------
Expand All @@ -824,7 +826,7 @@ async def delete_messages(
messages that were not removed. The
`BaseException.__cause__` of the exception will be the
original error that terminated this process.
""" # noqa: E501 - Line too long
"""
return await self.app.rest.delete_messages(self.id, messages, *other_messages)


Expand Down

0 comments on commit ca4193c

Please sign in to comment.