Skip to content

Commit 9a49719

Browse files
committed
Update ruff to target Python 3.11
1 parent 070255c commit 9a49719

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

docs/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changelog
99
- :breaking:`208` Drop support for Python 3.10
1010
- :breaking:`208` Drop support for Pydantic 1.X
1111
- :breaking:`207` Enable more ruff linting rules. See :literal-url:`GitHub release notes <https://github.com/python-discord/bot-core/releases/tag/v11.0.0>` for breaking changes.
12+
- :support:`208` Bump ruff to 0.3.0 and target Python 3.11 now that 3.10 isn't supported.
1213
- :support:`206` Bump ruff from 0.1.15 to 0.2.2, using the new lint config namespace, and linting with the new rules.
1314
- :support:`204` Document the instance attributes of :obj:`pydis_core.BotBase`.
1415

pydis_core/utils/_monkey_patches.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Contains all common monkey patches, used to alter discord to fit our needs."""
22

33
import logging
4-
from datetime import datetime, timedelta, timezone
4+
from datetime import UTC, datetime, timedelta
55
from functools import partial, partialmethod
66

77
from discord import Forbidden, http
@@ -50,13 +50,13 @@ def _patch_typing() -> None:
5050

5151
async def honeybadger_type(self: http.HTTPClient, channel_id: int) -> None:
5252
nonlocal last_403
53-
if last_403 and (datetime.now(tz=timezone.utc) - last_403) < timedelta(minutes=5):
53+
if last_403 and (datetime.now(tz=UTC) - last_403) < timedelta(minutes=5):
5454
log.warning("Not sending typing event, we got a 403 less than 5 minutes ago.")
5555
return
5656
try:
5757
await original(self, channel_id)
5858
except Forbidden:
59-
last_403 = datetime.now(tz=timezone.utc)
59+
last_403 = datetime.now(tz=UTC)
6060
log.warning("Got a 403 from typing event!")
6161

6262
http.HTTPClient.send_typing = honeybadger_type

pydis_core/utils/cooldown.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def from_full_arguments(cls, call_arguments: Iterable[object]) -> typing.Self:
8181
for item in call_arguments:
8282
try:
8383
hash(item)
84-
except TypeError: # noqa: PERF203
84+
except TypeError:
8585
non_hashable.append(item)
8686
else:
8787
hashable.append(item)

pydis_core/utils/pagination.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
from collections.abc import Sequence
32
from contextlib import suppress
43
from functools import partial
@@ -267,7 +266,7 @@ async def paginate(
267266
for line in lines:
268267
try:
269268
paginator.add_line(line, empty=empty)
270-
except Exception: # noqa: PERF203
269+
except Exception:
271270
log.exception(f"Failed to add line to paginator: '{line}'")
272271
raise # Should propagate
273272
else:
@@ -336,7 +335,7 @@ async def paginate(
336335
else:
337336
reaction, user = await ctx.bot.wait_for("reaction_add", timeout=timeout, check=check)
338337
log.trace(f"Got reaction: {reaction}")
339-
except asyncio.TimeoutError:
338+
except TimeoutError:
340339
log.debug("Timed out waiting for a reaction")
341340
break # We're done, no reactions for the last 5 minutes
342341

pydis_core/utils/scheduling.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import inspect
66
import typing
77
from collections import abc
8-
from datetime import datetime, timezone
8+
from datetime import UTC, datetime
99
from functools import partial
1010

1111
from discord.errors import Forbidden
@@ -103,7 +103,7 @@ def schedule_at(self, time: datetime, task_id: abc.Hashable, coroutine: abc.Coro
103103
task_id: A unique ID to create the task with.
104104
coroutine: The function to be called.
105105
"""
106-
now_datetime = datetime.now(time.tzinfo) if time.tzinfo else datetime.now(tz=timezone.utc)
106+
now_datetime = datetime.now(time.tzinfo) if time.tzinfo else datetime.now(tz=UTC)
107107
delay = (time - now_datetime).total_seconds()
108108
if delay > 0:
109109
coroutine = self._await_later(delay, task_id, coroutine)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ source_pkgs = ["pydis_core"]
7878
source = ["tests"]
7979

8080
[tool.ruff]
81-
target-version = "py310"
81+
target-version = "py311"
8282
extend-exclude = [".cache"]
8383
output-format = "concise"
8484
line-length = 120

0 commit comments

Comments
 (0)