Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
- id: check-merge-conflict
name: Merge Conflicts
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
name: Black Formatting
Expand Down
1 change: 0 additions & 1 deletion interactions/api/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def merge(self, item: _T, id: Optional["Key"] = None) -> None:
continue
# we can only assume that discord did not provide it, falsely deleting is worse than not deleting
if getattr(old_item, attrib) != getattr(item, attrib):

if isinstance(getattr(item, attrib), list) and not isinstance(
getattr(old_item, attrib), list
): # could be None
Expand Down
1 change: 0 additions & 1 deletion interactions/api/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def dispatch(self, name: str, /, *args, **kwargs) -> None:
if converters := getattr(event, "_converters", None):
_kwargs = kwargs.copy()
for key, value in _kwargs.items():

if key in converters.keys():
del kwargs[key]
kwargs[converters[key]] = value
Expand Down
1 change: 0 additions & 1 deletion interactions/api/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ def __init__(self, code: int = 0, message: str = None, severity: int = 0, **kwar
self.log(self.message)

if _fmt_error:

_flag: bool = (
self.message.lower() in self.lookup(self.code).lower()
) # creativity is hard
Expand Down
4 changes: 0 additions & 4 deletions interactions/api/gateway/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ async def _manage_heartbeat(self) -> None:
"""Manages the heartbeat loop."""
log.debug(f"Sending heartbeat every {self.__heartbeater.delay / 1000} seconds...")
while not self.__heartbeat_event.is_set():

log.debug("Sending heartbeat...")
if not self.__heartbeater.event.is_set():
log.debug("HEARTBEAT_ACK missing, reconnecting...")
Expand Down Expand Up @@ -967,7 +966,6 @@ async def __receive_packet(self, ignore_lock: bool = False) -> Optional[Dict[str
buffer = bytearray()

while True:

if not ignore_lock:
# meaning if we're reconnecting or something because of tasks
await self.__closed.wait()
Expand Down Expand Up @@ -1007,7 +1005,6 @@ async def __receive_packet(self, ignore_lock: bool = False) -> Optional[Dict[str
await self._reconnect(True)

elif packet.type == WSMsgType.CLOSING:

if ignore_lock:
raise LibraryException(
message="Discord unexpectedly closing on receiving by force.", severity=50
Expand Down Expand Up @@ -1065,7 +1062,6 @@ async def _send_packet(self, data: Dict[str, Any]) -> None:
await self._client.send_str(packet)
else:
async with self.reconnect_lock: # needs to lock while it reconnects.

if data["op"] != OpCodeType.HEARTBEAT.value:
# This is because the ratelimiter limits already accounts for this.
await self._ratelimiter.block()
Expand Down
2 changes: 0 additions & 2 deletions interactions/api/http/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ async def create_interaction_response(

file_data = None
if files:

file_data = MultipartWriter("form-data")
part = file_data.append_json(data)
part.set_content_disposition("form-data", name="payload_json")
Expand Down Expand Up @@ -295,7 +294,6 @@ async def edit_interaction_response(
# ^ again, I don't know if python will let me
file_data = None
if files:

file_data = MultipartWriter("form-data")
part = file_data.append_json(data)
part.set_content_disposition("form-data", name="payload_json")
Expand Down
2 changes: 0 additions & 2 deletions interactions/api/http/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ async def create_message(

data = None
if files is not MISSING and len(files) > 0:

data = MultipartWriter("form-data")
part = data.append_json(payload)
part.set_content_disposition("form-data", name="payload_json")
Expand Down Expand Up @@ -172,7 +171,6 @@ async def edit_message(
"""
data = None
if files is not MISSING and len(files) > 0:

data = MultipartWriter("form-data")
part = data.append_json(payload)
part.set_content_disposition("form-data", name="payload_json")
Expand Down
1 change: 0 additions & 1 deletion interactions/api/http/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ async def create_thread_in_forum(

data = None
if files is not MISSING and files and len(files) > 0: # edge case `None`

data = MultipartWriter("form-data")
part = data.append_json(payload)
part.set_content_disposition("form-data", name="payload_json")
Expand Down
1 change: 0 additions & 1 deletion interactions/api/http/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class UserRequest:

_req: _Request
cache: Cache

Expand Down
2 changes: 0 additions & 2 deletions interactions/api/http/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class WebhookRequest:

_req: _Request
cache: Cache

Expand Down Expand Up @@ -121,7 +120,6 @@ async def execute_webhook(

data = None
if files is not MISSING and len(files) > 0:

data = MultipartWriter("form-data")
part = data.append_json(payload)
part.set_content_disposition("form-data", name="payload_json")
Expand Down
4 changes: 0 additions & 4 deletions interactions/api/models/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ async def __anext__(self) -> "Message":
obj = self.objects.pop(0)

if self.check:

res = self.check(obj)
_res = await res if isawaitable(res) else res
while not _res:
Expand Down Expand Up @@ -272,7 +271,6 @@ def __init__(
obj: Union[int, str, "Snowflake", "Channel"],
_client: "HTTPClient",
):

try:
self.loop = get_running_loop()
except RuntimeError as e:
Expand Down Expand Up @@ -1325,7 +1323,6 @@ async def bulk_delete():
_allowed_time = datetime.now(tz=timezone.utc) - timedelta(days=14)
_stop = False
while amount > 100:

messages = [
Message(**res)
for res in await self._client.get_channel_messages(
Expand Down Expand Up @@ -1941,7 +1938,6 @@ async def create_forum_post(
_content["attachments"].append(attach._json)

else:

_data = await attach.download()

__files.append(File(attach.filename, _data))
Expand Down
5 changes: 0 additions & 5 deletions interactions/api/models/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ def __init__(
start_at: Optional[Union[int, str, Snowflake, Member]] = MISSING,
check: Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] = None,
):

self.__stop: bool = False

super().__init__(obj, _client, maximum=maximum, start_at=start_at, check=check)
Expand All @@ -258,7 +257,6 @@ def __init__(
self.objects: Optional[List[Member]]

async def get_first_objects(self) -> None:

limit = min(self.maximum, 1000)

if self.maximum == limit:
Expand All @@ -280,7 +278,6 @@ async def get_first_objects(self) -> None:
]

async def get_objects(self) -> None:

limit = min(500, self.maximum - self.object_count)
members = await self._client.get_list_of_members(
guild_id=self.object_id, after=self.after, limit=limit
Expand Down Expand Up @@ -309,7 +306,6 @@ async def __anext__(self) -> Member:
obj = self.objects.pop(0)

if self.check:

res = self.check(obj)
_res = await res if isawaitable(res) else res
while not _res:
Expand Down Expand Up @@ -2070,7 +2066,6 @@ async def get_all_bans(self) -> List[Dict[str, User]]:
res: list = await self._client.get_guild_bans(int(self.id), limit=1000)

while len(res) >= 1000:

for ban in res:
ban["user"] = User(**ban["user"])
_all.extend(res)
Expand Down
2 changes: 0 additions & 2 deletions interactions/api/models/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class File:
def __init__(
self, filename: str, fp: Optional[IOBase] = MISSING, description: Optional[str] = MISSING
):

if not isinstance(filename, str):
raise LibraryException(
message=f"File's first parameter 'filename' must be a string, not {str(type(filename))}",
Expand Down Expand Up @@ -378,7 +377,6 @@ class Image:
"""

def __init__(self, file: Union[str, FileIO], fp: Optional[IOBase] = MISSING):

self._URI = "data:image/"

if fp is MISSING or isinstance(file, FileIO):
Expand Down
3 changes: 0 additions & 3 deletions interactions/client/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ def __check_options(command, data):
return clean, _command

elif command.get("options") and data.get("options"):

clean = __check_options(command, data)

if not clean:
Expand Down Expand Up @@ -538,7 +537,6 @@ async def _get_all_guilds(self) -> List[dict]:
res = await self._http.get_self_guilds(limit=200)

while len(res) >= 200:

_all.extend(res)
_after = int(res[-1]["id"])

Expand Down Expand Up @@ -1513,7 +1511,6 @@ def remove(
for ext_name, ext in getmembers(
extension, lambda x: isinstance(x, type) and issubclass(x, Extension)
):

if ext_name != "Extension":
_extension = self._extensions.get(ext_name)
with contextlib.suppress(AttributeError):
Expand Down
2 changes: 0 additions & 2 deletions interactions/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ async def send(
and self.message
and self.callback == InteractionCallbackType.DEFERRED_UPDATE_MESSAGE
):

if isinstance(self.message.components, list):
_components = self.message.components
else:
Expand Down Expand Up @@ -552,7 +551,6 @@ def __attrs_post_init__(self) -> None:
async def edit(
self, content: Optional[str] = MISSING, **kwargs
) -> Message: # sourcery skip: low-code-quality

payload, files = await super().edit(content, **kwargs)
msg = None

Expand Down
1 change: 0 additions & 1 deletion interactions/client/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ def new(cls, *components: Union[Button, SelectMenu, TextInput]) -> List["ActionR
def _build_components(components) -> List[dict]:
# sourcery no-metrics
def __check_action_row():

if isinstance(components, list) and all(
isinstance(action_row, (list, ActionRow)) for action_row in components
):
Expand Down
1 change: 0 additions & 1 deletion interactions/utils/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ def _get_cache(
def _resolve_kwargs(obj, **kwargs):
# This function is needed to get correct kwarg names
if __id := kwargs.pop("parent_id", None):

if version_info >= (3, 9):
_list = [Message, List[Message], list[Message]]
else:
Expand Down