diff options
Diffstat (limited to 'pydis_core')
| -rw-r--r-- | pydis_core/utils/_monkey_patches.py | 6 | ||||
| -rw-r--r-- | pydis_core/utils/cooldown.py | 2 | ||||
| -rw-r--r-- | pydis_core/utils/pagination.py | 5 | ||||
| -rw-r--r-- | pydis_core/utils/scheduling.py | 4 | 
4 files changed, 8 insertions, 9 deletions
diff --git a/pydis_core/utils/_monkey_patches.py b/pydis_core/utils/_monkey_patches.py index 2df56039..f17aecce 100644 --- a/pydis_core/utils/_monkey_patches.py +++ b/pydis_core/utils/_monkey_patches.py @@ -1,7 +1,7 @@  """Contains all common monkey patches, used to alter discord to fit our needs."""  import logging -from datetime import datetime, timedelta, timezone +from datetime import UTC, datetime, timedelta  from functools import partial, partialmethod  from discord import Forbidden, http @@ -50,13 +50,13 @@ def _patch_typing() -> None:      async def honeybadger_type(self: http.HTTPClient, channel_id: int) -> None:          nonlocal last_403 -        if last_403 and (datetime.now(tz=timezone.utc) - last_403) < timedelta(minutes=5): +        if last_403 and (datetime.now(tz=UTC) - last_403) < timedelta(minutes=5):              log.warning("Not sending typing event, we got a 403 less than 5 minutes ago.")              return          try:              await original(self, channel_id)          except Forbidden: -            last_403 = datetime.now(tz=timezone.utc) +            last_403 = datetime.now(tz=UTC)              log.warning("Got a 403 from typing event!")      http.HTTPClient.send_typing = honeybadger_type diff --git a/pydis_core/utils/cooldown.py b/pydis_core/utils/cooldown.py index 91b9c5f3..d25d4507 100644 --- a/pydis_core/utils/cooldown.py +++ b/pydis_core/utils/cooldown.py @@ -81,7 +81,7 @@ class _SeparatedArguments:          for item in call_arguments:              try:                  hash(item) -            except TypeError:  # noqa: PERF203 +            except TypeError:                  non_hashable.append(item)              else:                  hashable.append(item) diff --git a/pydis_core/utils/pagination.py b/pydis_core/utils/pagination.py index 1d2b32c3..8282a930 100644 --- a/pydis_core/utils/pagination.py +++ b/pydis_core/utils/pagination.py @@ -1,4 +1,3 @@ -import asyncio  from collections.abc import Sequence  from contextlib import suppress  from functools import partial @@ -267,7 +266,7 @@ class LinePaginator(Paginator):          for line in lines:              try:                  paginator.add_line(line, empty=empty) -            except Exception:  # noqa: PERF203 +            except Exception:                  log.exception(f"Failed to add line to paginator: '{line}'")                  raise  # Should propagate              else: @@ -336,7 +335,7 @@ class LinePaginator(Paginator):                  else:                      reaction, user = await ctx.bot.wait_for("reaction_add", timeout=timeout, check=check)                  log.trace(f"Got reaction: {reaction}") -            except asyncio.TimeoutError: +            except TimeoutError:                  log.debug("Timed out waiting for a reaction")                  break  # We're done, no reactions for the last 5 minutes diff --git a/pydis_core/utils/scheduling.py b/pydis_core/utils/scheduling.py index 621fdd81..a3a5c8a0 100644 --- a/pydis_core/utils/scheduling.py +++ b/pydis_core/utils/scheduling.py @@ -5,7 +5,7 @@ import contextlib  import inspect  import typing  from collections import abc -from datetime import datetime, timezone +from datetime import UTC, datetime  from functools import partial  from discord.errors import Forbidden @@ -103,7 +103,7 @@ class Scheduler:              task_id: A unique ID to create the task with.              coroutine: The function to be called.          """ -        now_datetime = datetime.now(time.tzinfo) if time.tzinfo else datetime.now(tz=timezone.utc) +        now_datetime = datetime.now(time.tzinfo) if time.tzinfo else datetime.now(tz=UTC)          delay = (time - now_datetime).total_seconds()          if delay > 0:              coroutine = self._await_later(delay, task_id, coroutine)  |