aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_core/utils
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-02-19 21:27:16 +0000
committerGravatar Chris Lovering <[email protected]>2024-03-04 12:35:02 +0000
commit9c8fbd74b1d922f241c926cc26d609d0d13ae1c5 (patch)
tree0c2551275318d3ee0d64e4874121d54425ad4e4b /pydis_core/utils
parentruff lint fix: Add explicit namespaces for packages (diff)
ruff lint fix: Run remaining auto-fixable rules
Diffstat (limited to 'pydis_core/utils')
-rw-r--r--pydis_core/utils/function.py6
-rw-r--r--pydis_core/utils/interactions.py2
-rw-r--r--pydis_core/utils/members.py6
-rw-r--r--pydis_core/utils/pagination.py6
-rw-r--r--pydis_core/utils/paste_service.py3
5 files changed, 12 insertions, 11 deletions
diff --git a/pydis_core/utils/function.py b/pydis_core/utils/function.py
index 911f660d..0df3a953 100644
--- a/pydis_core/utils/function.py
+++ b/pydis_core/utils/function.py
@@ -6,7 +6,6 @@ import functools
import inspect
import types
import typing
-from collections.abc import Callable, Sequence, Set
__all__ = [
"GlobalNameConflictError",
@@ -19,6 +18,7 @@ __all__ = [
if typing.TYPE_CHECKING:
+ from collections.abc import Callable, Sequence, Set as AbstractSet
_P = typing.ParamSpec("_P")
_R = typing.TypeVar("_R")
@@ -114,7 +114,7 @@ def update_wrapper_globals(
wrapper: Callable[_P, _R],
wrapped: Callable[_P, _R],
*,
- ignored_conflict_names: Set[str] = frozenset(),
+ ignored_conflict_names: AbstractSet[str] = frozenset(),
) -> Callable[_P, _R]:
r"""
Create a copy of ``wrapper``\, the copy's globals are updated with ``wrapped``\'s globals.
@@ -174,7 +174,7 @@ def command_wraps(
assigned: Sequence[str] = functools.WRAPPER_ASSIGNMENTS,
updated: Sequence[str] = functools.WRAPPER_UPDATES,
*,
- ignored_conflict_names: Set[str] = frozenset(),
+ ignored_conflict_names: AbstractSet[str] = frozenset(),
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]:
r"""
Update the decorated function to look like ``wrapped``\, and update globals for discord.py forwardref evaluation.
diff --git a/pydis_core/utils/interactions.py b/pydis_core/utils/interactions.py
index 1710069d..7c5e5101 100644
--- a/pydis_core/utils/interactions.py
+++ b/pydis_core/utils/interactions.py
@@ -43,7 +43,7 @@ async def _handle_modify_message(message: Message, action: Literal["edit", "dele
elif isinstance(e, NotFound):
log.info(f"Could not find message {message.id} when attempting to {action} it.")
else:
- log.error(f"Could not {action} message {message.id} due to Discord HTTP error:\n{e!s}")
+ log.exception(f"Could not {action} message {message.id} due to Discord HTTP error:\n{e!s}")
class ViewWithUserAndRoleCheck(ui.View):
diff --git a/pydis_core/utils/members.py b/pydis_core/utils/members.py
index 542f945f..ff290436 100644
--- a/pydis_core/utils/members.py
+++ b/pydis_core/utils/members.py
@@ -49,11 +49,11 @@ async def handle_role_change(
try:
await coro(role)
except discord.NotFound:
- log.error(f"Failed to change role for {member} ({member.id}): member not found")
+ log.exception(f"Failed to change role for {member} ({member.id}): member not found")
except discord.Forbidden:
- log.error(
+ log.exception(
f"Forbidden to change role for {member} ({member.id}); "
f"possibly due to role hierarchy"
)
except discord.HTTPException as e:
- log.error(f"Failed to change role for {member} ({member.id}): {e.status} {e.code}")
+ log.exception(f"Failed to change role for {member} ({member.id}): {e.status} {e.code}")
diff --git a/pydis_core/utils/pagination.py b/pydis_core/utils/pagination.py
index a87bb290..aac75ae1 100644
--- a/pydis_core/utils/pagination.py
+++ b/pydis_core/utils/pagination.py
@@ -349,7 +349,7 @@ class LinePaginator(Paginator):
except discord.HTTPException as e:
# Suppress if trying to act on an archived thread.
if e.code != 50083:
- raise e
+ raise
if reaction.emoji == pagination_emojis.first:
current_page = 0
@@ -385,7 +385,7 @@ class LinePaginator(Paginator):
if e.code == 50083:
# Trying to act on an archived thread, just ignore and abort
break
- raise e
+ raise
log.debug("Ending pagination and clearing reactions.")
with suppress(discord.NotFound):
@@ -394,4 +394,4 @@ class LinePaginator(Paginator):
except discord.HTTPException as e:
# Suppress if trying to act on an archived thread.
if e.code != 50083:
- raise e
+ raise
diff --git a/pydis_core/utils/paste_service.py b/pydis_core/utils/paste_service.py
index 67f6a731..0c15b588 100644
--- a/pydis_core/utils/paste_service.py
+++ b/pydis_core/utils/paste_service.py
@@ -1,6 +1,7 @@
import json
from aiohttp import ClientConnectorError, ClientSession
+from aiohttp.web import HTTPException
from pydantic import BaseModel
from pydis_core.utils import logging
@@ -97,7 +98,7 @@ async def send_to_paste_service(
try:
async with http_session.get(f"{paste_url}/api/v1/lexer") as response:
response_json = await response.json() # Supported lexers are the keys.
- except Exception:
+ except HTTPException:
raise PasteUploadError("Could not fetch supported lexers from selected paste_url.")
_lexers_supported_by_pastebin[paste_url] = list(response_json)