Skip to content

Commit 796465c

Browse files
committed
🚨 🎨 Format code and fix linter warnings
Signed-off-by: Paillat-dev <[email protected]>
1 parent b9dead9 commit 796465c

File tree

19 files changed

+96
-507
lines changed

19 files changed

+96
-507
lines changed

discord/asset.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ def _from_avatar_decoration(cls, state, user_id: int, avatar_decoration: str) ->
207207
)
208208

209209
@classmethod
210-
def _from_user_primary_guild_tag(
211-
cls, state: ConnectionState, identity_guild_id: int, badge_id: str
212-
) -> Asset:
210+
def _from_user_primary_guild_tag(cls, state: ConnectionState, identity_guild_id: int, badge_id: str) -> Asset:
213211
"""Creates an Asset for a user's primary guild (tag) badge.
214212
215213
Parameters
@@ -274,9 +272,7 @@ def _from_cover_image(cls, state, object_id: int, cover_image_hash: str) -> Asse
274272
)
275273

276274
@classmethod
277-
def _from_collectible(
278-
cls, state: ConnectionState, asset: str, animated: bool = False
279-
) -> Asset:
275+
def _from_collectible(cls, state: ConnectionState, asset: str, animated: bool = False) -> Asset:
280276
name = "static.png" if not animated else "asset.webm"
281277
return cls(
282278
state,

discord/audit_logs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ def _transform_trigger_metadata(
196196
return AutoModTriggerMetadata.from_dict(data)
197197

198198

199-
def _transform_communication_disabled_until(
200-
entry: AuditLogEntry, data: str
201-
) -> datetime.datetime | None:
199+
def _transform_communication_disabled_until(entry: AuditLogEntry, data: str) -> datetime.datetime | None:
202200
if data:
203201
return datetime.datetime.fromisoformat(data)
204202
return None

discord/channel.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@
4949
InviteTarget,
5050
SortOrder,
5151
StagePrivacyLevel,
52-
)
53-
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
54-
from .enums import (
5552
VideoQualityMode,
5653
VoiceChannelEffectAnimationType,
5754
VoiceRegion,
5855
try_enum,
5956
)
57+
from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
6058
from .errors import ClientException, InvalidArgument
6159
from .file import File
6260
from .flags import ChannelFlags, MessageFlags
@@ -1062,9 +1060,7 @@ async def edit(
10621060
sync_permissions: bool = ...,
10631061
category: CategoryChannel | None = ...,
10641062
slowmode_delay: int = ...,
1065-
default_auto_archive_duration: (
1066-
ThreadArchiveDuration | ThreadArchiveDurationEnum
1067-
) = ...,
1063+
default_auto_archive_duration: (ThreadArchiveDuration | ThreadArchiveDurationEnum) = ...,
10681064
default_thread_slowmode_delay: int = ...,
10691065
default_sort_order: SortOrder = ...,
10701066
default_reaction_emoji: GuildEmoji | int | str | None = ...,
@@ -2801,9 +2797,7 @@ def __init__(self, *, state: ConnectionState, guild: Guild, data: CategoryChanne
28012797
self._update(guild, data)
28022798

28032799
def __repr__(self) -> str:
2804-
return (
2805-
f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}"
2806-
)
2800+
return f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}"
28072801

28082802
def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
28092803
# This data will always exist

discord/client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,4 @@ async def fetch_default_sounds(self) -> list[SoundboardSound]:
23252325
The bot's default sounds.
23262326
"""
23272327
data = await self._connection.http.get_default_sounds()
2328-
return [
2329-
SoundboardSound(http=self.http, state=self._connection, data=s)
2330-
for s in data
2331-
]
2328+
return [SoundboardSound(http=self.http, state=self._connection, data=s) for s in data]

discord/guild.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,11 @@ class Guild(Hashable):
292292
)
293293

294294
_PREMIUM_GUILD_LIMITS: ClassVar[dict[int | None, _GuildLimit]] = {
295-
None: _GuildLimit(
296-
emoji=50, stickers=5, soundboard=8, bitrate=96e3, filesize=10_485_760
297-
),
298-
0: _GuildLimit(
299-
emoji=50, stickers=5, soundboard=8, bitrate=96e3, filesize=10_485_760
300-
),
301-
1: _GuildLimit(
302-
emoji=100, stickers=15, soundboard=24, bitrate=128e3, filesize=10_485_760
303-
),
304-
2: _GuildLimit(
305-
emoji=150, stickers=30, soundboard=36, bitrate=256e3, filesize=52_428_800
306-
),
307-
3: _GuildLimit(
308-
emoji=250, stickers=60, soundboard=48, bitrate=384e3, filesize=104_857_600
309-
),
295+
None: _GuildLimit(emoji=50, stickers=5, soundboard=8, bitrate=96e3, filesize=10_485_760),
296+
0: _GuildLimit(emoji=50, stickers=5, soundboard=8, bitrate=96e3, filesize=10_485_760),
297+
1: _GuildLimit(emoji=100, stickers=15, soundboard=24, bitrate=128e3, filesize=10_485_760),
298+
2: _GuildLimit(emoji=150, stickers=30, soundboard=36, bitrate=256e3, filesize=52_428_800),
299+
3: _GuildLimit(emoji=250, stickers=60, soundboard=48, bitrate=384e3, filesize=104_857_600),
310300
}
311301

312302
def __init__(self, *, data: GuildPayload, state: ConnectionState):
@@ -650,9 +640,7 @@ async def create_sound(
650640
else:
651641
payload["emoji_id"] = partial_emoji.id
652642

653-
data = await self._state.http.create_guild_sound(
654-
self.id, reason=reason, **payload
655-
)
643+
data = await self._state.http.create_guild_sound(self.id, reason=reason, **payload)
656644
return SoundboardSound(
657645
state=self._state,
658646
http=self._state.http,
@@ -951,9 +939,7 @@ def soundboard_limit(self) -> int:
951939
.. versionadded:: 2.7
952940
"""
953941
more_soundboard = 48 if "MORE_SOUNDBOARD" in self.features else 0
954-
return max(
955-
more_soundboard, self._PREMIUM_GUILD_LIMITS[self.premium_tier].soundboard
956-
)
942+
return max(more_soundboard, self._PREMIUM_GUILD_LIMITS[self.premium_tier].soundboard)
957943

958944
@property
959945
def bitrate_limit(self) -> int:
@@ -1734,9 +1720,7 @@ async def create_forum_channel(
17341720
options["available_tags"] = [tag.to_dict() for tag in available_tags]
17351721

17361722
if default_sort_order is not MISSING:
1737-
options["default_sort_order"] = (
1738-
default_sort_order.value if default_sort_order else None
1739-
)
1723+
options["default_sort_order"] = default_sort_order.value if default_sort_order else None
17401724

17411725
if default_thread_slowmode_delay is not MISSING:
17421726
options["default_thread_slowmode_delay"] = default_thread_slowmode_delay
@@ -1757,9 +1741,7 @@ async def create_forum_channel(
17571741
raise InvalidArgument("default_reaction_emoji must be of type: GuildEmoji | int | str | None")
17581742

17591743
options["default_reaction_emoji"] = (
1760-
default_reaction_emoji._to_forum_reaction_payload()
1761-
if default_reaction_emoji
1762-
else None
1744+
default_reaction_emoji._to_forum_reaction_payload() if default_reaction_emoji else None
17631745
)
17641746

17651747
data = await self._create_channel(

discord/http.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,7 @@ def pins_from(
880880

881881
return self.request(r, params=params)
882882

883-
def legacy_pins_from(
884-
self, channel_id: Snowflake
885-
) -> Response[list[message.Message]]:
883+
def legacy_pins_from(self, channel_id: Snowflake) -> Response[list[message.Message]]:
886884
return self.request(Route("GET", "/channels/{channel_id}/pins", channel_id=channel_id))
887885

888886
# Member management
@@ -3028,9 +3026,7 @@ async def get_bot_gateway(self, *, encoding: str = "json", zlib: bool = True) ->
30283026
def get_user(self, user_id: Snowflake) -> Response[user.User]:
30293027
return self.request(Route("GET", "/users/{user_id}", user_id=user_id))
30303028

3031-
def delete_sound(
3032-
self, sound: SoundboardSound, *, reason: str | None
3033-
) -> Response[None]:
3029+
def delete_sound(self, sound: SoundboardSound, *, reason: str | None) -> Response[None]:
30343030
return self.request(
30353031
Route(
30363032
"DELETE",
@@ -3063,16 +3059,10 @@ def create_guild_sound(
30633059
reason=reason,
30643060
)
30653061

3066-
def get_all_guild_sounds(
3067-
self, guild_id: Snowflake
3068-
) -> Response[list[SoundboardSoundPayload]]:
3069-
return self.request(
3070-
Route("GET", "/guilds/{guild_id}/soundboard-sounds", guild_id=guild_id)
3071-
)
3062+
def get_all_guild_sounds(self, guild_id: Snowflake) -> Response[list[SoundboardSoundPayload]]:
3063+
return self.request(Route("GET", "/guilds/{guild_id}/soundboard-sounds", guild_id=guild_id))
30723064

3073-
def get_guild_sound(
3074-
self, guild_id: Snowflake, sound_id: Snowflake
3075-
) -> Response[SoundboardSoundPayload]:
3065+
def get_guild_sound(self, guild_id: Snowflake, sound_id: Snowflake) -> Response[SoundboardSoundPayload]:
30763066
return self.request(
30773067
Route(
30783068
"GET",
@@ -3105,9 +3095,7 @@ def edit_guild_sound(
31053095
reason=reason,
31063096
)
31073097

3108-
def send_soundboard_sound(
3109-
self, channel_id: int, sound: PartialSoundboardSound
3110-
) -> Response[None]:
3098+
def send_soundboard_sound(self, channel_id: int, sound: PartialSoundboardSound) -> Response[None]:
31113099
payload = {
31123100
"sound_id": sound.id,
31133101
}

discord/interactions.py

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -839,17 +839,15 @@ async def defer(self, *, ephemeral: bool = False, invisible: bool = True) -> Non
839839
if defer_type:
840840
adapter = async_context.get()
841841
http = parent._state.http
842-
callback_response: InteractionCallbackResponse = (
843-
await self._locked_response(
844-
adapter.create_interaction_response(
845-
parent.id,
846-
parent.token,
847-
session=parent._session,
848-
type=defer_type,
849-
data=data,
850-
proxy=http.proxy,
851-
proxy_auth=http.proxy_auth,
852-
)
842+
callback_response: InteractionCallbackResponse = await self._locked_response(
843+
adapter.create_interaction_response(
844+
parent.id,
845+
parent.token,
846+
session=parent._session,
847+
type=defer_type,
848+
data=data,
849+
proxy=http.proxy,
850+
proxy_auth=http.proxy_auth,
853851
)
854852
)
855853
self._responded = True
@@ -876,24 +874,20 @@ async def pong(self) -> None:
876874
if parent.type is InteractionType.ping:
877875
adapter = async_context.get()
878876
http = parent._state.http
879-
callback_response: InteractionCallbackResponse = (
880-
await self._locked_response(
881-
adapter.create_interaction_response(
882-
parent.id,
883-
parent.token,
884-
session=parent._session,
885-
proxy=http.proxy,
886-
proxy_auth=http.proxy_auth,
887-
type=InteractionResponseType.pong.value,
888-
)
877+
callback_response: InteractionCallbackResponse = await self._locked_response(
878+
adapter.create_interaction_response(
879+
parent.id,
880+
parent.token,
881+
session=parent._session,
882+
proxy=http.proxy,
883+
proxy_auth=http.proxy_auth,
884+
type=InteractionResponseType.pong.value,
889885
)
890886
)
891887
self._responded = True
892888
await self._process_callback_response(callback_response)
893889

894-
async def _process_callback_response(
895-
self, callback_response: InteractionCallbackResponse
896-
):
890+
async def _process_callback_response(self, callback_response: InteractionCallbackResponse):
897891
if callback_response.get("resource", {}).get("message"):
898892
# TODO: fix later to not raise?
899893
channel = self._parent.channel
@@ -1041,18 +1035,16 @@ async def send_message(
10411035
adapter = async_context.get()
10421036
http = parent._state.http
10431037
try:
1044-
callback_response: InteractionCallbackResponse = (
1045-
await self._locked_response(
1046-
adapter.create_interaction_response(
1047-
parent.id,
1048-
parent.token,
1049-
session=parent._session,
1050-
type=InteractionResponseType.channel_message.value,
1051-
proxy=http.proxy,
1052-
proxy_auth=http.proxy_auth,
1053-
data=payload,
1054-
files=files,
1055-
)
1038+
callback_response: InteractionCallbackResponse = await self._locked_response(
1039+
adapter.create_interaction_response(
1040+
parent.id,
1041+
parent.token,
1042+
session=parent._session,
1043+
type=InteractionResponseType.channel_message.value,
1044+
proxy=http.proxy,
1045+
proxy_auth=http.proxy_auth,
1046+
data=payload,
1047+
files=files,
10561048
)
10571049
)
10581050
finally:
@@ -1201,18 +1193,16 @@ async def edit_message(
12011193
adapter = async_context.get()
12021194
http = parent._state.http
12031195
try:
1204-
callback_response: InteractionCallbackResponse = (
1205-
await self._locked_response(
1206-
adapter.create_interaction_response(
1207-
parent.id,
1208-
parent.token,
1209-
session=parent._session,
1210-
type=InteractionResponseType.message_update.value,
1211-
proxy=http.proxy,
1212-
proxy_auth=http.proxy_auth,
1213-
data=payload,
1214-
files=files,
1215-
)
1196+
callback_response: InteractionCallbackResponse = await self._locked_response(
1197+
adapter.create_interaction_response(
1198+
parent.id,
1199+
parent.token,
1200+
session=parent._session,
1201+
type=InteractionResponseType.message_update.value,
1202+
proxy=http.proxy,
1203+
proxy_auth=http.proxy_auth,
1204+
data=payload,
1205+
files=files,
12161206
)
12171207
)
12181208
finally:
@@ -1705,12 +1695,8 @@ class InteractionCallback:
17051695
"""
17061696

17071697
def __init__(self, data: InteractionCallbackPayload):
1708-
self._response_message_loading: bool = data.get(
1709-
"response_message_loading", False
1710-
)
1711-
self._response_message_ephemeral: bool = data.get(
1712-
"response_message_ephemeral", False
1713-
)
1698+
self._response_message_loading: bool = data.get("response_message_loading", False)
1699+
self._response_message_ephemeral: bool = data.get("response_message_ephemeral", False)
17141700

17151701
def __repr__(self):
17161702
return (

discord/iterators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,8 @@ async def next(self) -> MessagePin:
11941194

11951195
try:
11961196
return self.queue.get_nowait()
1197-
except asyncio.QueueEmpty:
1198-
raise NoMoreItems()
1197+
except asyncio.QueueEmpty as e:
1198+
raise NoMoreItems() from e
11991199

12001200
@staticmethod
12011201
def get_last_pinned(data: MessagePinPayload) -> str:
@@ -1226,7 +1226,7 @@ async def fill_queue(self) -> None:
12261226
self.before = self.update_before(pins[-1])
12271227

12281228
def create_pin(self, data: MessagePinPayload) -> MessagePin:
1229-
from .message import MessagePin
1229+
from .message import MessagePin # noqa: PLC0415
12301230

12311231
return MessagePin(state=self.channel._state, channel=self.channel, data=data)
12321232

discord/member.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,7 @@ async def edit(
940940
bot_payload["bio"] = bio or ""
941941

942942
if bot_payload and not me:
943-
raise InvalidArgument(
944-
"Can only edit avatar, banner, or bio for the bot's member."
945-
)
943+
raise InvalidArgument("Can only edit avatar, banner, or bio for the bot's member.")
946944

947945
if payload:
948946
data = await http.edit_member(guild_id, self.id, reason=reason, **payload)

discord/message.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,7 @@ def __init__(
784784
):
785785
self._state: ConnectionState = state
786786
self._pinned_at: datetime.datetime = utils.parse_time(data["pinned_at"])
787-
self._message: Message = state.create_message(
788-
channel=channel, data=data["message"]
789-
)
787+
self._message: Message = state.create_message(channel=channel, data=data["message"])
790788

791789
@property
792790
def message(self) -> Message:

0 commit comments

Comments
 (0)