Skip to content

ci: weekly check. #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ __pycache__
/coverage.xml
/TestResults.xml
/.coverage
.mypy_cache/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ repos:
- id: check-merge-conflict
name: Merge Conflicts
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.6'
rev: 'v0.3.2'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.2.0
hooks:
- id: black
name: Black Formatting
Expand Down
1 change: 1 addition & 0 deletions interactions/api/events/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def some_func(self, event):
```
Returns:
A listener object.

"""
listener = models.Listener.create(cls().resolved_name)(coro)
client.add_listener(listener)
Expand Down
1 change: 1 addition & 0 deletions interactions/api/events/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async def an_event_handler(event: ChannelCreate):
While all of these events are documented, not all of them are used, currently.

"""

import re
import typing
from typing import Any, Optional, TYPE_CHECKING, Type
Expand Down
5 changes: 3 additions & 2 deletions interactions/api/gateway/gateway.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Outlines the interaction between interactions and Discord's Gateway API."""

import asyncio
import logging
import sys
Expand Down Expand Up @@ -161,7 +162,7 @@ async def run(self) -> None:
self.sequence = seq

if op == OPCODE.DISPATCH:
_ = asyncio.create_task(self.dispatch_event(data, seq, event))
_ = asyncio.create_task(self.dispatch_event(data, seq, event)) # noqa: RUF006
continue

# This may try to reconnect the connection so it is best to wait
Expand Down Expand Up @@ -229,7 +230,7 @@ async def dispatch_event(self, data, seq, event) -> None:
event_name = f"raw_{event.lower()}"
if processor := self.state.client.processors.get(event_name):
try:
_ = asyncio.create_task(
_ = asyncio.create_task( # noqa: RUF006
processor(events.RawGatewayEvent(data.copy(), override_name=event_name))
)
except Exception as ex:
Expand Down
1 change: 1 addition & 0 deletions interactions/api/gateway/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def wrapped_logger(self, level: int, message: str, **kwargs) -> None:
level: The logging level
message: The message to log
**kwargs: Any additional keyword arguments that Logger.log accepts

"""
self.logger.log(level, f"Shard ID {self.shard_id} | {message}", **kwargs)

Expand Down
6 changes: 2 additions & 4 deletions interactions/api/gateway/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,10 @@ async def _start_bee_gees(self) -> None:
return

@abstractmethod
async def _identify(self) -> None:
...
async def _identify(self) -> None: ...

@abstractmethod
async def _resume_connection(self) -> None:
...
async def _resume_connection(self) -> None: ...

@abstractmethod
async def send_heartbeat(self) -> None:
Expand Down
10 changes: 9 additions & 1 deletion interactions/api/http/http_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This file handles the interaction with discords http endpoints."""

import asyncio
import inspect
import os
Expand Down Expand Up @@ -80,6 +81,7 @@ def set_reset_time(self, delta: float) -> None:

Args:
delta: The time to wait before resetting the calls.

"""
self._reset_time = time.perf_counter() + delta
self._calls = 0
Expand Down Expand Up @@ -134,6 +136,7 @@ def ingest_ratelimit_header(self, header: CIMultiDictProxy) -> None:
header: The header to ingest, containing rate limit information.

Updates the bucket_hash, limit, remaining, and delta attributes with the information from the header.

"""
self.bucket_hash = header.get("x-ratelimit-bucket")
self.limit = int(header.get("x-ratelimit-limit", self.DEFAULT_LIMIT))
Expand Down Expand Up @@ -179,6 +182,7 @@ async def lock_for_duration(self, duration: float, block: bool = False) -> None:

Raises:
RuntimeError: If the bucket is already locked.

"""
if self._lock.locked():
raise RuntimeError("Attempted to lock a bucket that is already locked.")
Expand All @@ -192,7 +196,7 @@ async def _release() -> None:
await _release()
else:
await self._lock.acquire()
_ = asyncio.create_task(_release())
_ = asyncio.create_task(_release()) # noqa: RUF006

async def __aenter__(self) -> None:
await self.acquire()
Expand Down Expand Up @@ -255,6 +259,7 @@ def get_ratelimit(self, route: Route) -> BucketLock:

Returns:
The BucketLock object for this route

"""
if bucket_hash := self._endpoints.get(route.rl_bucket):
if lock := self.ratelimit_locks.get(bucket_hash):
Expand All @@ -272,6 +277,7 @@ def ingest_ratelimit(self, route: Route, header: CIMultiDictProxy, bucket_lock:
route: The route we're ingesting ratelimit for
header: The rate limit header in question
bucket_lock: The rate limit bucket for this route

"""
bucket_lock.ingest_ratelimit_header(header)

Expand All @@ -294,6 +300,7 @@ def _process_payload(

Returns:
Either a dictionary or multipart data form

"""
if isinstance(payload, FormData):
return payload
Expand Down Expand Up @@ -483,6 +490,7 @@ def log_ratelimit(self, log_func: Callable, message: str) -> None:
Args:
log_func: The logging function to use
message: The message to log

"""
if self.show_ratelimit_traceback:
if frame := next(
Expand Down
24 changes: 10 additions & 14 deletions interactions/api/http/http_requests/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ async def get_channel_messages(
self,
channel_id: "Snowflake_Type",
limit: int = 50,
) -> list[discord_typings.MessageData]:
...
) -> list[discord_typings.MessageData]: ...

@overload
async def get_channel_messages(
Expand All @@ -51,8 +50,7 @@ async def get_channel_messages(
limit: int = 50,
*,
around: "Snowflake_Type | None" = None,
) -> list[discord_typings.MessageData]:
...
) -> list[discord_typings.MessageData]: ...

@overload
async def get_channel_messages(
Expand All @@ -61,8 +59,7 @@ async def get_channel_messages(
limit: int = 50,
*,
before: "Snowflake_Type | None" = None,
) -> list[discord_typings.MessageData]:
...
) -> list[discord_typings.MessageData]: ...

@overload
async def get_channel_messages(
Expand All @@ -71,8 +68,7 @@ async def get_channel_messages(
limit: int = 50,
*,
after: "Snowflake_Type | None" = None,
) -> list[discord_typings.MessageData]:
...
) -> list[discord_typings.MessageData]: ...

async def get_channel_messages(
self,
Expand Down Expand Up @@ -263,8 +259,7 @@ async def create_channel_invite(
unique: bool = False,
*,
reason: str | None = None,
) -> discord_typings.InviteData:
...
) -> discord_typings.InviteData: ...

@overload
async def create_channel_invite(
Expand All @@ -277,8 +272,7 @@ async def create_channel_invite(
*,
target_user_id: "Snowflake_Type | None" = None,
reason: str | None = None,
) -> discord_typings.InviteData:
...
) -> discord_typings.InviteData: ...

@overload
async def create_channel_invite(
Expand All @@ -291,8 +285,7 @@ async def create_channel_invite(
*,
target_application_id: "Snowflake_Type | None" = None,
reason: str | None = None,
) -> discord_typings.InviteData:
...
) -> discord_typings.InviteData: ...

async def create_channel_invite(
self,
Expand Down Expand Up @@ -598,6 +591,7 @@ async def create_tag(
!!! note
Can either have an `emoji_id` or an `emoji_name`, but not both.
`emoji_id` is meant for custom emojis, `emoji_name` is meant for unicode emojis.

"""
payload: PAYLOAD_TYPE = {
"name": name,
Expand Down Expand Up @@ -632,6 +626,7 @@ async def edit_tag(
!!! note
Can either have an `emoji_id` or an `emoji_name`, but not both.
emoji`_id is meant for custom emojis, `emoji_name` is meant for unicode emojis.

"""
payload: PAYLOAD_TYPE = {
"name": name,
Expand All @@ -652,6 +647,7 @@ async def delete_tag(self, channel_id: "Snowflake_Type", tag_id: "Snowflake_Type
Args:
channel_id: The ID of the forum channel to delete tag it.
tag_id: The ID of the tag to delete

"""
result = await self.request(
Route("DELETE", "/channels/{channel_id}/tags/{tag_id}", channel_id=channel_id, tag_id=tag_id)
Expand Down
3 changes: 3 additions & 0 deletions interactions/api/http/http_requests/entitlements.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def get_entitlements(

Returns:
A dictionary containing the application's entitlements.

"""
params: PAYLOAD_TYPE = {
"user_id": to_optional_snowflake(user_id),
Expand All @@ -65,6 +66,7 @@ async def create_test_entitlement(self, payload: dict, application_id: "Snowflak

Returns:
A dictionary containing the test entitlement.

"""
return await self.request(
Route("POST", "/applications/{application_id}/entitlements", application_id=application_id), payload=payload
Expand All @@ -77,6 +79,7 @@ async def delete_test_entitlement(self, application_id: "Snowflake_Type", entitl
Args:
application_id: The ID of the application.
entitlement_id: The ID of the entitlement.

"""
await self.request(
Route(
Expand Down
6 changes: 6 additions & 0 deletions interactions/api/http/http_requests/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ async def get_guild_channels(

Returns:
A list of channels in this guild. Does not include threads.

"""
result = await self.request(Route("GET", "/guilds/{guild_id}/channels", guild_id=guild_id))
return cast(list[discord_typings.ChannelData], result)
Expand Down Expand Up @@ -927,6 +928,7 @@ async def get_auto_moderation_rules(

Returns:
A list of auto moderation rules

"""
result = await self.request(Route("GET", "/guilds/{guild_id}/auto-moderation/rules", guild_id=guild_id))
return cast(list[dict], result)
Expand All @@ -943,6 +945,7 @@ async def get_auto_moderation_rule(

Returns:
The auto moderation rule

"""
result = await self.request(
Route("GET", "/guilds/{guild_id}/auto-moderation/rules/{rule_id}", guild_id=guild_id, rule_id=rule_id)
Expand All @@ -961,6 +964,7 @@ async def create_auto_moderation_rule(

Returns:
The created auto moderation rule

"""
result = await self.request(
Route("POST", "/guilds/{guild_id}/auto-moderation/rules", guild_id=guild_id), payload=payload
Expand Down Expand Up @@ -999,6 +1003,7 @@ async def modify_auto_moderation_rule(

Returns:
The updated rule object

"""
payload = {
"name": name,
Expand Down Expand Up @@ -1029,6 +1034,7 @@ async def delete_auto_moderation_rule(
guild_id: The ID of the guild to delete this rule from
rule_id: The ID of the role to delete
reason: The reason for deleting this rule

"""
result = await self.request(
Route("DELETE", "/guilds/{guild_id}/auto-moderation/rules/{rule_id}", guild_id=guild_id, rule_id=rule_id),
Expand Down
1 change: 1 addition & 0 deletions interactions/api/http/http_requests/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ async def create_application_command(

Returns:
An application command object

"""
if guild_id == GLOBAL_SCOPE:
result = await self.request(
Expand Down
1 change: 1 addition & 0 deletions interactions/api/http/http_requests/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ async def create_forum_thread(

Returns:
The created thread object

"""
return await self.request(
Route("POST", "/channels/{channel_id}/threads", channel_id=channel_id),
Expand Down
7 changes: 7 additions & 0 deletions interactions/api/voice/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def extend(self, data: bytes) -> None:

Args:
data: The data to add

"""
with self._lock:
self._buffer.extend(data)
Expand All @@ -102,6 +103,7 @@ def read(self, total_bytes: int, *, pad: bool = True) -> bytearray:

Raises:
ValueError: If `pad` is False and the buffer does not contain enough data.

"""
with self._lock:
view = memoryview(self._buffer)
Expand Down Expand Up @@ -129,6 +131,7 @@ def read_max(self, total_bytes: int) -> bytearray:

Raises:
EOFError: If the buffer is empty.

"""
with self._lock:
if len(self._buffer) == 0:
Expand Down Expand Up @@ -170,6 +173,7 @@ def read(self, frame_size: int) -> bytes:

Returns:
bytes of audio

"""
...

Expand Down Expand Up @@ -304,6 +308,7 @@ def pre_buffer(self, duration: None | float = None) -> None:

Args:
duration: The duration of audio to pre-buffer.

"""
if duration:
self.buffer_seconds = duration
Expand All @@ -322,6 +327,7 @@ def read(self, frame_size: int) -> bytes:

Returns:
bytes of audio

"""
if not self.process:
self._create_process()
Expand Down Expand Up @@ -369,6 +375,7 @@ def read(self, frame_size: int) -> bytes:

Returns:
bytes of audio

"""
data = super().read(frame_size)
return audioop.mul(data, 2, self._volume)
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy