Skip to content

Commit 83f8918

Browse files
committed
🚨 Fix ruff warnings
1 parent a89c94a commit 83f8918

File tree

27 files changed

+78
-1041
lines changed

27 files changed

+78
-1041
lines changed

discord/abc.py

Lines changed: 2 additions & 962 deletions
Large diffs are not rendered by default.

discord/app/event_emitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, state: "ConnectionState") -> None:
9191
self._events: dict[str, list[type[Event]]] = defaultdict(list)
9292
self._state: ConnectionState = state
9393

94-
from ..events import ALL_EVENTS # noqa: PLC0415
94+
from ..events import ALL_EVENTS
9595

9696
for event_cls in ALL_EVENTS:
9797
self.add_event(event_cls)

discord/appinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class AppInfo:
183183
)
184184

185185
def __init__(self, state: ConnectionState, data: AppInfoPayload):
186-
from .team import Team # noqa: PLC0415
186+
from .team import Team
187187

188188
self._state: ConnectionState = state
189189
self.id: int = int(data["id"])

discord/audit_logs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ async def _from_data(
351351
before = await self._maybe_await(transformer(entry, before))
352352

353353
if attr == "location" and hasattr(self.before, "location_type"):
354-
from .scheduled_events import ScheduledEventLocation # noqa: PLC0415
354+
from .scheduled_events import ScheduledEventLocation
355355

356356
if self.before.location_type is enums.ScheduledEventLocationType.external:
357357
before = ScheduledEventLocation(state=state, value=before)
@@ -369,7 +369,7 @@ async def _from_data(
369369
after = await self._maybe_await(transformer(entry, after))
370370

371371
if attr == "location" and hasattr(self.after, "location_type"):
372-
from .scheduled_events import ScheduledEventLocation # noqa: PLC0415
372+
from .scheduled_events import ScheduledEventLocation
373373

374374
if self.after.location_type is enums.ScheduledEventLocationType.external:
375375
after = ScheduledEventLocation(state=state, value=after)

discord/channel/base.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333

3434
from typing_extensions import Self, TypeVar, override
3535

36-
from ..abc import Messageable, Snowflake, User, _Overwrites
36+
from ..abc import Messageable, Snowflake, SnowflakeTime, User, _Overwrites, _purge_messages_helper
3737
from ..emoji import GuildEmoji, PartialEmoji
3838
from ..enums import ChannelType, InviteTarget, SortOrder, try_enum
39+
from ..errors import ClientException
3940
from ..flags import ChannelFlags, MessageFlags
4041
from ..iterators import ArchivedThreadIterator
4142
from ..mixins import Hashable
4243
from ..utils import MISSING, Undefined, find, snowflake_time
43-
from ..utils.private import copy_doc, get_as_snowflake
44+
from ..utils.private import SnowflakeList, bytes_to_base64_data, copy_doc, get_as_snowflake
4445

4546
if TYPE_CHECKING:
4647
from ..embeds import Embed
@@ -50,7 +51,7 @@
5051
from ..invite import Invite
5152
from ..member import Member
5253
from ..mentions import AllowedMentions
53-
from ..message import EmojiInputType, Message
54+
from ..message import EmojiInputType, Message, PartialMessage
5455
from ..object import Object
5556
from ..partial_emoji import _EmojiTag
5657
from ..permissions import PermissionOverwrite, Permissions
@@ -69,8 +70,10 @@
6970
from ..types.channel import VoiceChannel as VoiceChannelPayload
7071
from ..types.guild import ChannelPositionUpdate as ChannelPositionUpdatePayload
7172
from ..ui.view import View
73+
from ..webhook import Webhook
7274
from .category import CategoryChannel
7375
from .channel import ForumTag
76+
from .text import TextChannel
7477
from .thread import Thread
7578

7679
_log = logging.getLogger(__name__)
@@ -1172,7 +1175,7 @@ async def move(self, **kwargs: Any) -> None:
11721175
)
11731176

11741177

1175-
class GuildThreadableChannel(ABC):
1178+
class GuildThreadableChannel:
11761179
"""An ABC for guild channels that support thread creation.
11771180
11781181
This includes text, news, forum, and media channels.
@@ -1735,7 +1738,7 @@ async def get_last_message(self) -> Message | None:
17351738
"""
17361739
return await self._state._get_message(self.last_message_id) if self.last_message_id else None
17371740

1738-
async def edit(self, **options) -> _TextChannel:
1741+
async def edit(self, **options) -> Self:
17391742
"""Edits the channel."""
17401743
raise NotImplementedError
17411744

@@ -1807,7 +1810,7 @@ async def purge(
18071810
self,
18081811
*,
18091812
limit: int | None = 100,
1810-
check: Callable[[Message], bool] | utils.Undefined = MISSING,
1813+
check: Callable[[Message], bool] | Undefined = MISSING,
18111814
before: SnowflakeTime | None = None,
18121815
after: SnowflakeTime | None = None,
18131816
around: SnowflakeTime | None = None,
@@ -1873,7 +1876,7 @@ def is_me(m):
18731876
deleted = await channel.purge(limit=100, check=is_me)
18741877
await channel.send(f"Deleted {len(deleted)} message(s)")
18751878
"""
1876-
return await discord.abc._purge_messages_helper(
1879+
return await _purge_messages_helper(
18771880
self,
18781881
limit=limit,
18791882
check=check,
@@ -1985,6 +1988,7 @@ async def follow(self, *, destination: TextChannel, reason: str | None = None) -
19851988
"""
19861989

19871990
from .news import NewsChannel
1991+
from .text import TextChannel
19881992

19891993
if not isinstance(self, NewsChannel):
19901994
raise ClientException("The channel must be a news channel.")

discord/channel/category.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def move(self, **kwargs):
176176
await super().move(**kwargs)
177177

178178
@property
179-
def channels(self) -> list[GuildChannelType]:
179+
def channels(self) -> list[GuildTopLevelChannel]:
180180
"""Returns the channels that are under this category.
181181
182182
These are sorted by the official Discord UI, which places voice channels below the text channels.

discord/channel/news.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from ..types.channel import NewsChannel as NewsChannelPayload
4242
from ..types.channel import TextChannel as TextChannelPayload
4343
from .category import CategoryChannel
44+
from .text import TextChannel
4445
from .thread import Thread
4546

4647
__all__ = ("NewsChannel",)

discord/channel/text.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from ..types.channel import NewsChannel as NewsChannelPayload
4242
from ..types.channel import TextChannel as TextChannelPayload
4343
from .category import CategoryChannel
44+
from .news import NewsChannel
4445
from .thread import Thread
4546

4647
__all__ = ("TextChannel",)

discord/channel/thread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def applied_tags(self) -> list[ForumTag]:
281281
282282
This is only available for threads in forum or media channels.
283283
"""
284-
from .channel import ForumChannel # noqa: PLC0415 # to prevent circular import
284+
from .channel import ForumChannel # to prevent circular import
285285

286286
if isinstance(self.parent, ForumChannel):
287287
return [tag for tag_id in self._applied_tags if (tag := self.parent.get_tag(tag_id)) is not None]
@@ -816,7 +816,7 @@ def get_partial_message(self, message_id: int, /) -> PartialMessage:
816816
The partial message.
817817
"""
818818

819-
from .message import PartialMessage # noqa: PLC0415
819+
from .message import PartialMessage
820820

821821
return PartialMessage(channel=self, id=message_id)
822822

discord/channel/voice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def create_activity_invite(self, activity: EmbeddedActivity | int, **kwarg
273273
HTTPException
274274
Invite creation failed.
275275
"""
276-
from ..enums import EmbeddedActivity # noqa: PLC0415
276+
from ..enums import EmbeddedActivity
277277

278278
if isinstance(activity, EmbeddedActivity):
279279
activity = activity.value

0 commit comments

Comments
 (0)