Skip to content

Commit 0ea2077

Browse files
style(pre-commit): auto fixes from pre-commit.com hooks
1 parent a98025a commit 0ea2077

File tree

10 files changed

+93
-84
lines changed

10 files changed

+93
-84
lines changed

discord/gateway.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from __future__ import annotations
2727

2828
import asyncio
29-
from collections.abc import Callable
3029
import concurrent.futures
3130
import logging
3231
import struct
@@ -36,6 +35,7 @@
3635
import traceback
3736
import zlib
3837
from collections import deque
38+
from collections.abc import Callable
3939
from typing import TYPE_CHECKING, Any, NamedTuple
4040

4141
import aiohttp
@@ -318,7 +318,12 @@ class DiscordWebSocket:
318318
shard_count: int | None
319319
_max_heartbeat_timeout: float
320320

321-
def __init__(self, socket: aiohttp.ClientWebSocketResponse, *, loop: asyncio.AbstractEventLoop) -> None:
321+
def __init__(
322+
self,
323+
socket: aiohttp.ClientWebSocketResponse,
324+
*,
325+
loop: asyncio.AbstractEventLoop,
326+
) -> None:
322327
self.socket: aiohttp.ClientWebSocketResponse = socket
323328
self.loop: asyncio.AbstractEventLoop = loop
324329

@@ -652,7 +657,7 @@ async def poll_event(self) -> None:
652657
elif msg.type is aiohttp.WSMsgType.BINARY:
653658
await self.received_message(msg.data)
654659
elif msg.type is aiohttp.WSMsgType.ERROR:
655-
_log.debug('Received an error %s', msg)
660+
_log.debug("Received an error %s", msg)
656661
elif msg.type in (
657662
aiohttp.WSMsgType.CLOSED,
658663
aiohttp.WSMsgType.CLOSING,

discord/raw_models.py

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525

2626
from __future__ import annotations
2727

28-
from collections.abc import ItemsView, KeysView, ValuesView
2928
import datetime
29+
from collections.abc import ItemsView, KeysView, ValuesView
3030
from typing import TYPE_CHECKING, Any
3131

32+
from . import utils
3233
from .automod import AutoModAction, AutoModTriggerType
3334
from .enums import AuditLogAction, ChannelType, ReactionType, try_enum
34-
from . import utils
3535

3636
if TYPE_CHECKING:
37-
from .abc import MessageableChannel, GuildChannel
37+
from .abc import GuildChannel, MessageableChannel
3838
from .guild import Guild
3939
from .member import Member
4040
from .message import Message
@@ -94,7 +94,11 @@ class _RawReprMixin:
9494
__slots__: tuple[str, ...]
9595

9696
def __repr__(self) -> str:
97-
value = " ".join(f"{attr}={getattr(self, attr)!r}" for attr in self.__slots__ if not attr.startswith('_'))
97+
value = " ".join(
98+
f"{attr}={getattr(self, attr)!r}"
99+
for attr in self.__slots__
100+
if not attr.startswith("_")
101+
)
98102
return f"<{self.__class__.__name__} {value}>"
99103

100104

@@ -850,23 +854,24 @@ def __init__(self, data: MessagePollVoteEvent, added: bool) -> None:
850854
except KeyError:
851855
self.guild_id: int | None = None
852856

857+
853858
# this is for backwards compatibility because VoiceProtocol.on_voice_..._update
854859
# passed the raw payload instead of a raw object. Emit deprecation warning.
855860
class _PayloadLike(_RawReprMixin):
856861
_raw_data: dict[str, Any]
857862

858863
@utils.deprecated(
859-
'the attributes',
860-
'2.7',
861-
'3.0',
864+
"the attributes",
865+
"2.7",
866+
"3.0",
862867
)
863868
def __getitem__(self, key: str) -> Any:
864869
return self._raw_data[key]
865870

866871
@utils.deprecated(
867-
'the attributes',
868-
'2.7',
869-
'3.0',
872+
"the attributes",
873+
"2.7",
874+
"3.0",
870875
)
871876
def get(self, key: str, default: Any = None) -> Any:
872877
"""Gets an item from this raw event, and returns its value or ``default``.
@@ -877,9 +882,9 @@ def get(self, key: str, default: Any = None) -> Any:
877882
return self._raw_data.get(key, default)
878883

879884
@utils.deprecated(
880-
'the attributes',
881-
'2.7',
882-
'3.0',
885+
"the attributes",
886+
"2.7",
887+
"3.0",
883888
)
884889
def items(self) -> ItemsView:
885890
"""Returns the (key, value) pairs of this raw event.
@@ -890,9 +895,9 @@ def items(self) -> ItemsView:
890895
return self._raw_data.items()
891896

892897
@utils.deprecated(
893-
'the attributes',
894-
'2.7',
895-
'3.0',
898+
"the attributes",
899+
"2.7",
900+
"3.0",
896901
)
897902
def values(self) -> ValuesView:
898903
"""Returns the values of this raw event.
@@ -903,9 +908,9 @@ def values(self) -> ValuesView:
903908
return self._raw_data.values()
904909

905910
@utils.deprecated(
906-
'the attributes',
907-
'2.7',
908-
'3.0',
911+
"the attributes",
912+
"2.7",
913+
"3.0",
909914
)
910915
def keys(self) -> KeysView:
911916
"""Returns the keys of this raw event.
@@ -957,37 +962,37 @@ class RawVoiceStateUpdateEvent(_PayloadLike):
957962
"""
958963

959964
__slots__ = (
960-
'session_id',
961-
'mute',
962-
'deaf',
963-
'self_mute',
964-
'self_deaf',
965-
'self_stream',
966-
'self_video',
967-
'suppress',
968-
'requested_to_speak_at',
969-
'afk',
970-
'channel',
971-
'guild_id',
972-
'channel_id',
973-
'_state',
974-
'_raw_data',
965+
"session_id",
966+
"mute",
967+
"deaf",
968+
"self_mute",
969+
"self_deaf",
970+
"self_stream",
971+
"self_video",
972+
"suppress",
973+
"requested_to_speak_at",
974+
"afk",
975+
"channel",
976+
"guild_id",
977+
"channel_id",
978+
"_state",
979+
"_raw_data",
975980
)
976981

977982
def __init__(self, *, data: VoiceStateEvent, state: ConnectionState) -> None:
978-
self.session_id: str = data['session_id']
983+
self.session_id: str = data["session_id"]
979984
self._state: ConnectionState = state
980985

981-
self.self_mute: bool = data.get('self_mute', False)
982-
self.self_deaf: bool = data.get('self_deaf', False)
983-
self.mute: bool = data.get('mute', False)
984-
self.deaf: bool = data.get('deaf', False)
985-
self.suppress: bool = data.get('suppress', False)
986+
self.self_mute: bool = data.get("self_mute", False)
987+
self.self_deaf: bool = data.get("self_deaf", False)
988+
self.mute: bool = data.get("mute", False)
989+
self.deaf: bool = data.get("deaf", False)
990+
self.suppress: bool = data.get("suppress", False)
986991
self.requested_to_speak_at: datetime.datetime | None = utils.parse_time(
987-
data.get('request_to_speak_timestamp')
992+
data.get("request_to_speak_timestamp")
988993
)
989-
self.guild_id: int | None = utils._get_as_snowflake(data, 'guild_id')
990-
self.channel_id: int | None = utils._get_as_snowflake(data, 'channel_id')
994+
self.guild_id: int | None = utils._get_as_snowflake(data, "guild_id")
995+
self.channel_id: int | None = utils._get_as_snowflake(data, "channel_id")
991996
self._raw_data: VoiceStateEvent = data
992997

993998
@property
@@ -1017,18 +1022,18 @@ class RawVoiceServerUpdateEvent(_PayloadLike):
10171022
"""
10181023

10191024
__slots__ = (
1020-
'token',
1021-
'guild_id',
1022-
'endpoint',
1023-
'_raw_data',
1024-
'_state',
1025+
"token",
1026+
"guild_id",
1027+
"endpoint",
1028+
"_raw_data",
1029+
"_state",
10251030
)
10261031

10271032
def __init__(self, *, data: VoiceServerUpdateEvent, state: ConnectionState) -> None:
10281033
self._state: ConnectionState = state
1029-
self.guild_id: int = int(data['guild_id'])
1030-
self.token: str = data['token']
1031-
self.endpoint: str | None = data['endpoint']
1034+
self.guild_id: int = int(data["guild_id"])
1035+
self.token: str = data["token"]
1036+
self.endpoint: str | None = data["endpoint"]
10321037

10331038
@property
10341039
def guild(self) -> Guild | None:

discord/types/raw_models.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@
3333
from .snowflake import Snowflake
3434
from .threads import Thread, ThreadMember
3535
from .user import User
36-
from .voice import (
37-
VoiceState as VoiceStateEvent,
38-
VoiceServerUpdate as VoiceServerUpdateEvent,
39-
)
36+
from .voice import VoiceServerUpdate as VoiceServerUpdateEvent
37+
from .voice import VoiceState as VoiceStateEvent
4038

4139

4240
class _MessageEventOptional(TypedDict, total=False):

discord/voice/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
:license: MIT, see LICENSE for more details.
99
"""
1010

11-
from .client import VoiceClient
1211
from ._types import VoiceProtocol
12+
from .client import VoiceClient
1313

1414
__all__ = (
15-
'VoiceClient',
16-
'VoiceProtocol',
15+
"VoiceClient",
16+
"VoiceProtocol",
1717
)

discord/voice/_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.
2424
"""
25+
2526
from __future__ import annotations
2627

2728
from typing import TYPE_CHECKING, Generic, TypeVar
@@ -30,11 +31,11 @@
3031
from discord import abc
3132
from discord.client import Client
3233
from discord.raw_models import (
33-
RawVoiceStateUpdateEvent,
3434
RawVoiceServerUpdateEvent,
35+
RawVoiceStateUpdateEvent,
3536
)
3637

37-
ClientT = TypeVar('ClientT', bound='Client', covariant=True)
38+
ClientT = TypeVar("ClientT", bound="Client", covariant=True)
3839

3940

4041
class VoiceProtocol(Generic[ClientT]):

discord/voice/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.
2424
"""
25+
2526
from __future__ import annotations
2627

2728
from ._types import VoiceProtocol

discord/voice/errors.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.
2424
"""
25+
2526
from __future__ import annotations
2627

2728
from aiohttp import ClientWebSocketResponse
@@ -46,10 +47,10 @@ class VoiceConnectionClosed(ClientException):
4647
"""
4748

4849
__slots__ = (
49-
'code',
50-
'reason',
51-
'channel_id',
52-
'guild_id',
50+
"code",
51+
"reason",
52+
"channel_id",
53+
"guild_id",
5354
)
5455

5556
def __init__(
@@ -83,8 +84,8 @@ class VoiceGuildMismatch(ClientException):
8384
"""
8485

8586
__slots__ = (
86-
'expected',
87-
'received',
87+
"expected",
88+
"received",
8889
)
8990

9091
def __init__(self, expt: int, recv: int) -> None:

discord/voice/gateway.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2323
DEALINGS IN THE SOFTWARE.
2424
"""
25+
2526
from __future__ import annotations
2627

2728
import asyncio
28-
from collections.abc import Callable, Coroutine
2929
import logging
30+
from collections.abc import Callable, Coroutine
3031
from typing import TYPE_CHECKING, Any
3132

3233
import aiohttp
@@ -73,7 +74,7 @@ def _hook(self, *args: Any) -> Any:
7374
pass
7475

7576
async def send_as_json(self, data: Any) -> None:
76-
_log.debug('Sending voice websocket frame: %s', data)
77+
_log.debug("Sending voice websocket frame: %s", data)
7778
await self.ws.send_str(utils._to_json(data))
7879

7980
send_heartbeat = send_as_json
@@ -88,5 +89,5 @@ async def resume(self) -> None:
8889
self.ws,
8990
channel_id=self.state.channel_id,
9091
guild_id=self.state.guild_id,
91-
reason='The library attempted a resume when it was not expected',
92+
reason="The library attempted a resume when it was not expected",
9293
)

0 commit comments

Comments
 (0)