Skip to content

Commit 79e926c

Browse files
style(pre-commit): auto fixes from pre-commit.com hooks
1 parent 8304dba commit 79e926c

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

discord/gateway.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import time
3434
import traceback
3535
import zlib
36-
from collections import deque
3736
from collections.abc import Callable
3837
from typing import TYPE_CHECKING, Any, NamedTuple
3938

discord/voice/gateway.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
from typing import TYPE_CHECKING, Any
3636

3737
import aiohttp
38-
3938
import davey
39+
4040
from discord import utils
4141
from discord.enums import SpeakingState
4242
from discord.errors import ConnectionClosed
@@ -152,7 +152,9 @@ async def _hook(self, *args: Any) -> Any:
152152

153153
async def send_as_bytes(self, op: int, data: bytes) -> None:
154154
packet = bytes(op) + data
155-
_log.debug("Sending voice websocket binary frame: op: %s data: %s", op, str(data))
155+
_log.debug(
156+
"Sending voice websocket binary frame: op: %s data: %s", op, str(data)
157+
)
156158
await self.ws.send_bytes(packet)
157159

158160
async def send_as_json(self, data: Any) -> None:
@@ -208,7 +210,10 @@ async def received_message(self, msg: Any, /):
208210
self._keep_alive.start()
209211
elif self.dave_session:
210212
if op == OpCodes.dave_prepare_transition:
211-
_log.info("Preparing to upgrade to a DAVE connection for channel %s", state.channel_id)
213+
_log.info(
214+
"Preparing to upgrade to a DAVE connection for channel %s",
215+
state.channel_id,
216+
)
212217
state.dave_pending_transition = data
213218

214219
transition_id = data["transition_id"]
@@ -220,11 +225,17 @@ async def received_message(self, msg: Any, /):
220225
self.dave_session.set_passthrough_mode(True, 120)
221226
await self.send_dave_transition_ready(transition_id)
222227
elif op == OpCodes.dave_execute_transition:
223-
_log.info("Upgrading to DAVE connection for channel %s", state.channel_id)
228+
_log.info(
229+
"Upgrading to DAVE connection for channel %s", state.channel_id
230+
)
224231
await state.execute_dave_transition(data["transition_id"])
225232
elif op == OpCodes.dave_prepare_epoch:
226233
epoch = data["epoch"]
227-
_log.debug("Preparing for DAVE epoch in channel %s: %s", state.channel_id, epoch)
234+
_log.debug(
235+
"Preparing for DAVE epoch in channel %s: %s",
236+
state.channel_id,
237+
epoch,
238+
)
228239
# if epoch is 1 then a new MLS group is to be created for the proto version
229240
if epoch == 1:
230241
state.dave_protocol_version = data["protocol_version"]
@@ -237,7 +248,12 @@ async def received_message(self, msg: Any, /):
237248
async def received_binary_message(self, msg: bytes) -> None:
238249
self.seq_ack = struct.unpack_from(">H", msg, 0)[0]
239250
op = msg[2]
240-
_log.debug("Voice websocket binary frame received: %d bytes, seq: %s, op: %s", len(msg), self.seq_ack, op)
251+
_log.debug(
252+
"Voice websocket binary frame received: %d bytes, seq: %s, op: %s",
253+
len(msg),
254+
self.seq_ack,
255+
op,
256+
)
241257

242258
state = self.state
243259

@@ -249,14 +265,22 @@ async def received_binary_message(self, msg: bytes) -> None:
249265
elif op == OpCodes.mls_proposals:
250266
op_type = msg[3]
251267
result = self.dave_session.process_proposals(
252-
davey.ProposalsOperationType.append if op_type == 0 else davey.ProposalsOperationType.revoke,
268+
(
269+
davey.ProposalsOperationType.append
270+
if op_type == 0
271+
else davey.ProposalsOperationType.revoke
272+
),
253273
msg[4:],
254274
)
255275

256276
if isinstance(result, davey.CommitWelcome):
257277
await self.send_as_bytes(
258278
OpCodes.mls_key_package.value,
259-
(result.commit + result.welcome) if result.welcome else result.commit,
279+
(
280+
(result.commit + result.welcome)
281+
if result.welcome
282+
else result.commit
283+
),
260284
)
261285
_log.debug("Processed MLS proposals for current dave session")
262286
elif op == OpCodes.mls_commit_transition:
@@ -271,7 +295,10 @@ async def received_binary_message(self, msg: bytes) -> None:
271295
await self.send_dave_transition_ready(transt_id)
272296
_log.debug("Processed MLS commit for transition %s", transt_id)
273297
except Exception as exc:
274-
_log.debug("An exception ocurred while processing a MLS commit, this should be safe to ignore: %s", exc)
298+
_log.debug(
299+
"An exception ocurred while processing a MLS commit, this should be safe to ignore: %s",
300+
exc,
301+
)
275302
await state.recover_dave_from_invalid_commit(transt_id)
276303
elif op == OpCodes.mls_welcome:
277304
transt_id = struct.unpack_from(">H", msg, 3)[0]
@@ -285,7 +312,10 @@ async def received_binary_message(self, msg: bytes) -> None:
285312
await self.send_dave_transition_ready(transt_id)
286313
_log.debug("Processed MLS welcome for transition %s", transt_id)
287314
except Exception as exc:
288-
_log.debug("An exception ocurred while processing a MLS welcome, this should be safe to ignore: %s", exc)
315+
_log.debug(
316+
"An exception ocurred while processing a MLS welcome, this should be safe to ignore: %s",
317+
exc,
318+
)
289319
await state.recover_dave_from_invalid_commit(transt_id)
290320

291321
async def ready(self, data: dict[str, Any]) -> None:

discord/voice/state.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
from collections.abc import Callable, Coroutine
3636
from typing import TYPE_CHECKING, Any, TypedDict
3737

38+
import davey
39+
3840
from discord import opus, utils
3941
from discord.backoff import ExponentialBackoff
4042
from discord.enums import SpeakingState, try_enum
4143
from discord.errors import ConnectionClosed
4244
from discord.object import Object
4345
from discord.sinks import RawData, Sink
4446

45-
import davey
46-
4747
from .enums import ConnectionFlowState, OpCodes
4848
from .gateway import VoiceWebSocket
4949

@@ -1211,7 +1211,9 @@ async def reinit_dave_session(self) -> None:
12111211

12121212
if self.dave_protocol_version > 0:
12131213
if session:
1214-
session.reinit(self.dave_protocol_version, self.user.id, self.channel_id)
1214+
session.reinit(
1215+
self.dave_protocol_version, self.user.id, self.channel_id
1216+
)
12151217
else:
12161218
session = self.dave_session = davey.DaveSession(
12171219
self.dave_protocol_version,
@@ -1255,8 +1257,13 @@ async def execute_dave_transition(self, transition: int) -> None:
12551257
old_version = self.dave_protocol_version
12561258
self.dave_protocol_version = pending_proto
12571259

1258-
if old_version != self.dave_protocol_version and self.dave_protocol_version == 0:
1259-
_log.warning("DAVE was downgraded, voice client non-e2ee session has been deprecated since 2.7")
1260+
if (
1261+
old_version != self.dave_protocol_version
1262+
and self.dave_protocol_version == 0
1263+
):
1264+
_log.warning(
1265+
"DAVE was downgraded, voice client non-e2ee session has been deprecated since 2.7"
1266+
)
12601267
self.downgraded_dave = True
12611268
elif transition > 0 and self.downgraded_dave:
12621269
self.downgraded_dave = False

0 commit comments

Comments
 (0)