diff options
-rw-r--r-- | docs/conf.py | 4 | ||||
-rw-r--r-- | docs/netlify_build.py | 2 | ||||
-rw-r--r-- | docs/utils.py | 4 | ||||
-rw-r--r-- | pydis_core/utils/function.py | 6 | ||||
-rw-r--r-- | pydis_core/utils/interactions.py | 2 | ||||
-rw-r--r-- | pydis_core/utils/members.py | 6 | ||||
-rw-r--r-- | pydis_core/utils/pagination.py | 6 | ||||
-rw-r--r-- | pydis_core/utils/paste_service.py | 3 | ||||
-rw-r--r-- | tests/pydis_core/utils/test_cooldown.py | 2 |
9 files changed, 17 insertions, 18 deletions
diff --git a/docs/conf.py b/docs/conf.py index 2b68fc0f..5205b013 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -120,9 +120,7 @@ def skip(*args) -> bool: name = args[2] would_skip = args[4] - if name in ( - "__weakref__", - ): + if name == "__weakref__": return True return would_skip diff --git a/docs/netlify_build.py b/docs/netlify_build.py index a6da74df..4c35e6ba 100644 --- a/docs/netlify_build.py +++ b/docs/netlify_build.py @@ -23,4 +23,4 @@ OUTPUT.write_text(build_script.text, encoding="utf-8") if __name__ == "__main__": # Run the build script print("Build started") # noqa: T201 - subprocess.run([sys.executable, OUTPUT.absolute()]) # noqa: S603 + subprocess.run([sys.executable, OUTPUT.absolute()], check=False) # noqa: S603 diff --git a/docs/utils.py b/docs/utils.py index 18a457b7..796eca3d 100644 --- a/docs/utils.py +++ b/docs/utils.py @@ -74,11 +74,11 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> str | for name in symbol_name.split("."): try: symbol.append(getattr(symbol[-1], name)) - except AttributeError as e: + except AttributeError: # This could be caused by trying to link a class attribute if is_attribute(symbol[-1], name): break - raise e + raise symbol_name = name 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) diff --git a/tests/pydis_core/utils/test_cooldown.py b/tests/pydis_core/utils/test_cooldown.py index eed16da3..45e74bd4 100644 --- a/tests/pydis_core/utils/test_cooldown.py +++ b/tests/pydis_core/utils/test_cooldown.py @@ -1,7 +1,7 @@ import unittest from unittest.mock import patch -from pydis_core.utils.cooldown import _CommandCooldownManager, _create_argument_tuple +from pydis_core.utils.cooldown import _CommandCooldownManager, _create_argument_tuple # noqa: PLC2701 class CommandCooldownManagerTests(unittest.IsolatedAsyncioTestCase): |