Skip to content

Commit 05cbcc8

Browse files
ci: weekly check. (#1594)
* ci: weekly check. updates: - [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.3.2](astral-sh/ruff-pre-commit@v0.1.6...v0.3.2) - [github.com/psf/black: 23.11.0 → 24.2.0](psf/black@23.11.0...24.2.0) * ci: correct from checks. * chore: Acknowledge where we're intentionally discarding created tasks (RUF006) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Katelyn Gigante <clockwork.singularity@gmail.com>
1 parent 0df1e19 commit 05cbcc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+402
-125
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ __pycache__
1818
/coverage.xml
1919
/TestResults.xml
2020
/.coverage
21+
.mypy_cache/

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ repos:
3030
- id: check-merge-conflict
3131
name: Merge Conflicts
3232
- repo: https://github.com/astral-sh/ruff-pre-commit
33-
rev: 'v0.1.6'
33+
rev: 'v0.3.2'
3434
hooks:
3535
- id: ruff
3636
args: [--fix, --exit-non-zero-on-fix]
3737
- repo: https://github.com/psf/black
38-
rev: 23.11.0
38+
rev: 24.2.0
3939
hooks:
4040
- id: black
4141
name: Black Formatting

interactions/api/events/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ async def some_func(self, event):
5959
```
6060
Returns:
6161
A listener object.
62+
6263
"""
6364
listener = models.Listener.create(cls().resolved_name)(coro)
6465
client.add_listener(listener)

interactions/api/events/internal.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async def an_event_handler(event: ChannelCreate):
1919
While all of these events are documented, not all of them are used, currently.
2020
2121
"""
22+
2223
import re
2324
import typing
2425
from typing import Any, Optional, TYPE_CHECKING, Type

interactions/api/gateway/gateway.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Outlines the interaction between interactions and Discord's Gateway API."""
2+
23
import asyncio
34
import logging
45
import sys
@@ -161,7 +162,7 @@ async def run(self) -> None:
161162
self.sequence = seq
162163

163164
if op == OPCODE.DISPATCH:
164-
_ = asyncio.create_task(self.dispatch_event(data, seq, event))
165+
_ = asyncio.create_task(self.dispatch_event(data, seq, event)) # noqa: RUF006
165166
continue
166167

167168
# This may try to reconnect the connection so it is best to wait
@@ -229,7 +230,7 @@ async def dispatch_event(self, data, seq, event) -> None:
229230
event_name = f"raw_{event.lower()}"
230231
if processor := self.state.client.processors.get(event_name):
231232
try:
232-
_ = asyncio.create_task(
233+
_ = asyncio.create_task( # noqa: RUF006
233234
processor(events.RawGatewayEvent(data.copy(), override_name=event_name))
234235
)
235236
except Exception as ex:

interactions/api/gateway/state.py

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def wrapped_logger(self, level: int, message: str, **kwargs) -> None:
138138
level: The logging level
139139
message: The message to log
140140
**kwargs: Any additional keyword arguments that Logger.log accepts
141+
141142
"""
142143
self.logger.log(level, f"Shard ID {self.shard_id} | {message}", **kwargs)
143144

interactions/api/gateway/websocket.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,10 @@ async def _start_bee_gees(self) -> None:
315315
return
316316

317317
@abstractmethod
318-
async def _identify(self) -> None:
319-
...
318+
async def _identify(self) -> None: ...
320319

321320
@abstractmethod
322-
async def _resume_connection(self) -> None:
323-
...
321+
async def _resume_connection(self) -> None: ...
324322

325323
@abstractmethod
326324
async def send_heartbeat(self) -> None:

interactions/api/http/http_client.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This file handles the interaction with discords http endpoints."""
2+
23
import asyncio
34
import inspect
45
import os
@@ -80,6 +81,7 @@ def set_reset_time(self, delta: float) -> None:
8081
8182
Args:
8283
delta: The time to wait before resetting the calls.
84+
8385
"""
8486
self._reset_time = time.perf_counter() + delta
8587
self._calls = 0
@@ -134,6 +136,7 @@ def ingest_ratelimit_header(self, header: CIMultiDictProxy) -> None:
134136
header: The header to ingest, containing rate limit information.
135137
136138
Updates the bucket_hash, limit, remaining, and delta attributes with the information from the header.
139+
137140
"""
138141
self.bucket_hash = header.get("x-ratelimit-bucket")
139142
self.limit = int(header.get("x-ratelimit-limit", self.DEFAULT_LIMIT))
@@ -179,6 +182,7 @@ async def lock_for_duration(self, duration: float, block: bool = False) -> None:
179182
180183
Raises:
181184
RuntimeError: If the bucket is already locked.
185+
182186
"""
183187
if self._lock.locked():
184188
raise RuntimeError("Attempted to lock a bucket that is already locked.")
@@ -192,7 +196,7 @@ async def _release() -> None:
192196
await _release()
193197
else:
194198
await self._lock.acquire()
195-
_ = asyncio.create_task(_release())
199+
_ = asyncio.create_task(_release()) # noqa: RUF006
196200

197201
async def __aenter__(self) -> None:
198202
await self.acquire()
@@ -255,6 +259,7 @@ def get_ratelimit(self, route: Route) -> BucketLock:
255259
256260
Returns:
257261
The BucketLock object for this route
262+
258263
"""
259264
if bucket_hash := self._endpoints.get(route.rl_bucket):
260265
if lock := self.ratelimit_locks.get(bucket_hash):
@@ -272,6 +277,7 @@ def ingest_ratelimit(self, route: Route, header: CIMultiDictProxy, bucket_lock:
272277
route: The route we're ingesting ratelimit for
273278
header: The rate limit header in question
274279
bucket_lock: The rate limit bucket for this route
280+
275281
"""
276282
bucket_lock.ingest_ratelimit_header(header)
277283

@@ -294,6 +300,7 @@ def _process_payload(
294300
295301
Returns:
296302
Either a dictionary or multipart data form
303+
297304
"""
298305
if isinstance(payload, FormData):
299306
return payload
@@ -483,6 +490,7 @@ def log_ratelimit(self, log_func: Callable, message: str) -> None:
483490
Args:
484491
log_func: The logging function to use
485492
message: The message to log
493+
486494
"""
487495
if self.show_ratelimit_traceback:
488496
if frame := next(

interactions/api/http/http_requests/channels.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ async def get_channel_messages(
4141
self,
4242
channel_id: "Snowflake_Type",
4343
limit: int = 50,
44-
) -> list[discord_typings.MessageData]:
45-
...
44+
) -> list[discord_typings.MessageData]: ...
4645

4746
@overload
4847
async def get_channel_messages(
@@ -51,8 +50,7 @@ async def get_channel_messages(
5150
limit: int = 50,
5251
*,
5352
around: "Snowflake_Type | None" = None,
54-
) -> list[discord_typings.MessageData]:
55-
...
53+
) -> list[discord_typings.MessageData]: ...
5654

5755
@overload
5856
async def get_channel_messages(
@@ -61,8 +59,7 @@ async def get_channel_messages(
6159
limit: int = 50,
6260
*,
6361
before: "Snowflake_Type | None" = None,
64-
) -> list[discord_typings.MessageData]:
65-
...
62+
) -> list[discord_typings.MessageData]: ...
6663

6764
@overload
6865
async def get_channel_messages(
@@ -71,8 +68,7 @@ async def get_channel_messages(
7168
limit: int = 50,
7269
*,
7370
after: "Snowflake_Type | None" = None,
74-
) -> list[discord_typings.MessageData]:
75-
...
71+
) -> list[discord_typings.MessageData]: ...
7672

7773
async def get_channel_messages(
7874
self,
@@ -263,8 +259,7 @@ async def create_channel_invite(
263259
unique: bool = False,
264260
*,
265261
reason: str | None = None,
266-
) -> discord_typings.InviteData:
267-
...
262+
) -> discord_typings.InviteData: ...
268263

269264
@overload
270265
async def create_channel_invite(
@@ -277,8 +272,7 @@ async def create_channel_invite(
277272
*,
278273
target_user_id: "Snowflake_Type | None" = None,
279274
reason: str | None = None,
280-
) -> discord_typings.InviteData:
281-
...
275+
) -> discord_typings.InviteData: ...
282276

283277
@overload
284278
async def create_channel_invite(
@@ -291,8 +285,7 @@ async def create_channel_invite(
291285
*,
292286
target_application_id: "Snowflake_Type | None" = None,
293287
reason: str | None = None,
294-
) -> discord_typings.InviteData:
295-
...
288+
) -> discord_typings.InviteData: ...
296289

297290
async def create_channel_invite(
298291
self,
@@ -600,6 +593,7 @@ async def create_tag(
600593
!!! note
601594
Can either have an `emoji_id` or an `emoji_name`, but not both.
602595
`emoji_id` is meant for custom emojis, `emoji_name` is meant for unicode emojis.
596+
603597
"""
604598
payload: PAYLOAD_TYPE = {
605599
"name": name,
@@ -635,6 +629,7 @@ async def edit_tag(
635629
!!! note
636630
Can either have an `emoji_id` or an `emoji_name`, but not both.
637631
emoji`_id is meant for custom emojis, `emoji_name` is meant for unicode emojis.
632+
638633
"""
639634
payload: PAYLOAD_TYPE = {
640635
"name": name,
@@ -655,6 +650,7 @@ async def delete_tag(self, channel_id: "Snowflake_Type", tag_id: "Snowflake_Type
655650
Args:
656651
channel_id: The ID of the forum channel to delete tag it.
657652
tag_id: The ID of the tag to delete
653+
658654
"""
659655
result = await self.request(
660656
Route("DELETE", "/channels/{channel_id}/tags/{tag_id}", channel_id=channel_id, tag_id=tag_id)

interactions/api/http/http_requests/entitlements.py

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async def get_entitlements(
3939
4040
Returns:
4141
A dictionary containing the application's entitlements.
42+
4243
"""
4344
params: PAYLOAD_TYPE = {
4445
"user_id": to_optional_snowflake(user_id),
@@ -65,6 +66,7 @@ async def create_test_entitlement(self, payload: dict, application_id: "Snowflak
6566
6667
Returns:
6768
A dictionary containing the test entitlement.
69+
6870
"""
6971
return await self.request(
7072
Route("POST", "/applications/{application_id}/entitlements", application_id=application_id), payload=payload
@@ -77,6 +79,7 @@ async def delete_test_entitlement(self, application_id: "Snowflake_Type", entitl
7779
Args:
7880
application_id: The ID of the application.
7981
entitlement_id: The ID of the entitlement.
82+
8083
"""
8184
await self.request(
8285
Route(

interactions/api/http/http_requests/guild.py

+6
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ async def get_guild_channels(
637637
638638
Returns:
639639
A list of channels in this guild. Does not include threads.
640+
640641
"""
641642
result = await self.request(Route("GET", "/guilds/{guild_id}/channels", guild_id=guild_id))
642643
return cast(list[discord_typings.ChannelData], result)
@@ -927,6 +928,7 @@ async def get_auto_moderation_rules(
927928
928929
Returns:
929930
A list of auto moderation rules
931+
930932
"""
931933
result = await self.request(Route("GET", "/guilds/{guild_id}/auto-moderation/rules", guild_id=guild_id))
932934
return cast(list[dict], result)
@@ -943,6 +945,7 @@ async def get_auto_moderation_rule(
943945
944946
Returns:
945947
The auto moderation rule
948+
946949
"""
947950
result = await self.request(
948951
Route("GET", "/guilds/{guild_id}/auto-moderation/rules/{rule_id}", guild_id=guild_id, rule_id=rule_id)
@@ -961,6 +964,7 @@ async def create_auto_moderation_rule(
961964
962965
Returns:
963966
The created auto moderation rule
967+
964968
"""
965969
result = await self.request(
966970
Route("POST", "/guilds/{guild_id}/auto-moderation/rules", guild_id=guild_id), payload=payload
@@ -999,6 +1003,7 @@ async def modify_auto_moderation_rule(
9991003
10001004
Returns:
10011005
The updated rule object
1006+
10021007
"""
10031008
payload = {
10041009
"name": name,
@@ -1029,6 +1034,7 @@ async def delete_auto_moderation_rule(
10291034
guild_id: The ID of the guild to delete this rule from
10301035
rule_id: The ID of the role to delete
10311036
reason: The reason for deleting this rule
1037+
10321038
"""
10331039
result = await self.request(
10341040
Route("DELETE", "/guilds/{guild_id}/auto-moderation/rules/{rule_id}", guild_id=guild_id, rule_id=rule_id),

interactions/api/http/http_requests/interactions.py

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ async def create_application_command(
117117
118118
Returns:
119119
An application command object
120+
120121
"""
121122
if guild_id == GLOBAL_SCOPE:
122123
result = await self.request(

interactions/api/http/http_requests/threads.py

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ async def create_forum_thread(
249249
250250
Returns:
251251
The created thread object
252+
252253
"""
253254
return await self.request(
254255
Route("POST", "/channels/{channel_id}/threads", channel_id=channel_id),

interactions/api/voice/audio.py

+7
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def extend(self, data: bytes) -> None:
8585
8686
Args:
8787
data: The data to add
88+
8889
"""
8990
with self._lock:
9091
self._buffer.extend(data)
@@ -102,6 +103,7 @@ def read(self, total_bytes: int, *, pad: bool = True) -> bytearray:
102103
103104
Raises:
104105
ValueError: If `pad` is False and the buffer does not contain enough data.
106+
105107
"""
106108
with self._lock:
107109
view = memoryview(self._buffer)
@@ -129,6 +131,7 @@ def read_max(self, total_bytes: int) -> bytearray:
129131
130132
Raises:
131133
EOFError: If the buffer is empty.
134+
132135
"""
133136
with self._lock:
134137
if len(self._buffer) == 0:
@@ -170,6 +173,7 @@ def read(self, frame_size: int) -> bytes:
170173
171174
Returns:
172175
bytes of audio
176+
173177
"""
174178
...
175179

@@ -304,6 +308,7 @@ def pre_buffer(self, duration: None | float = None) -> None:
304308
305309
Args:
306310
duration: The duration of audio to pre-buffer.
311+
307312
"""
308313
if duration:
309314
self.buffer_seconds = duration
@@ -322,6 +327,7 @@ def read(self, frame_size: int) -> bytes:
322327
323328
Returns:
324329
bytes of audio
330+
325331
"""
326332
if not self.process:
327333
self._create_process()
@@ -369,6 +375,7 @@ def read(self, frame_size: int) -> bytes:
369375
370376
Returns:
371377
bytes of audio
378+
372379
"""
373380
data = super().read(frame_size)
374381
return audioop.mul(data, 2, self._volume)

0 commit comments

Comments
 (0)