aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2025-10-30 21:26:14 +0000
committerGravatar Joe Banks <[email protected]>2025-11-10 18:41:30 +0000
commit3d17675d2a06db60f4a1ce14f9afe4b1301cccaa (patch)
treeec5cbe05437a03b4911702a233e1cf8801ba9aff
parentUpdate Ruff to latest version 0.14.2 (diff)
Ruff fixes for Python 3.14 and Ruff 0.14.2
-rw-r--r--bot/__init__.py2
-rw-r--r--bot/exts/backend/sync/_syncers.py4
-rw-r--r--bot/exts/filtering/_filter_lists/antispam.py2
-rw-r--r--bot/exts/filtering/_filter_lists/filter_list.py6
-rw-r--r--bot/exts/filtering/_ui/filter.py2
-rw-r--r--bot/exts/filtering/_ui/search.py4
-rw-r--r--bot/exts/filtering/_ui/ui.py2
-rw-r--r--bot/exts/filtering/_utils.py4
-rw-r--r--bot/exts/recruitment/talentpool/_cog.py2
-rw-r--r--bot/exts/utils/reminders.py2
-rw-r--r--bot/utils/function.py2
-rw-r--r--tests/bot/exts/moderation/test_incidents.py8
-rw-r--r--tests/bot/utils/test_messages.py3
13 files changed, 22 insertions, 21 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index 290ca682b..ebd4fc212 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -17,4 +17,4 @@ if os.name == "nt":
apply_monkey_patches()
-instance: "Bot" = None # Global Bot instance.
+instance: Bot = None # Global Bot instance.
diff --git a/bot/exts/backend/sync/_syncers.py b/bot/exts/backend/sync/_syncers.py
index 88f34e9a8..9a5671deb 100644
--- a/bot/exts/backend/sync/_syncers.py
+++ b/bot/exts/backend/sync/_syncers.py
@@ -225,10 +225,10 @@ class UserSyncer(Syncer):
# Using asyncio.gather would still consume too many resources on the site.
log.trace("Syncing created users...")
if diff.created:
- for chunk in batched(diff.created, CHUNK_SIZE):
+ for chunk in batched(diff.created, CHUNK_SIZE, strict=False):
await bot.instance.api_client.post("bot/users", json=chunk)
log.trace("Syncing updated users...")
if diff.updated:
- for chunk in batched(diff.updated, CHUNK_SIZE):
+ for chunk in batched(diff.updated, CHUNK_SIZE, strict=False):
await bot.instance.api_client.patch("bot/users/bulk_patch", json=chunk)
diff --git a/bot/exts/filtering/_filter_lists/antispam.py b/bot/exts/filtering/_filter_lists/antispam.py
index f27412e1a..ecb895e01 100644
--- a/bot/exts/filtering/_filter_lists/antispam.py
+++ b/bot/exts/filtering/_filter_lists/antispam.py
@@ -40,7 +40,7 @@ class AntispamList(UniquesListBase):
name = "antispam"
- def __init__(self, filtering_cog: "Filtering"):
+ def __init__(self, filtering_cog: Filtering):
super().__init__(filtering_cog)
self.message_deletion_queue: dict[Member, DeletionContext] = dict()
diff --git a/bot/exts/filtering/_filter_lists/filter_list.py b/bot/exts/filtering/_filter_lists/filter_list.py
index 2cc54e8fb..9c47a03c1 100644
--- a/bot/exts/filtering/_filter_lists/filter_list.py
+++ b/bot/exts/filtering/_filter_lists/filter_list.py
@@ -90,7 +90,7 @@ class AtomicList:
self, ctx: FilterContext, defaults: Defaults, filters: Iterable[Filter]
) -> list[Filter]:
"""A helper function to evaluate the result of `filter_list_result`."""
- passed_by_default, failed_by_default = defaults.validations.evaluate(ctx)
+ _passed_by_default, failed_by_default = defaults.validations.evaluate(ctx)
default_answer = not bool(failed_by_default)
relevant_filters = []
@@ -160,7 +160,7 @@ class AtomicList:
T = typing.TypeVar("T", bound=Filter)
-class FilterList(dict[ListType, AtomicList], typing.Generic[T], FieldRequiring):
+class FilterList[T](dict[ListType, AtomicList], FieldRequiring):
"""Dispatches events to lists of _filters, and aggregates the responses into a single list of actions to take."""
# Each subclass must define a name matching the filter_list name we're expecting to receive from the database.
@@ -268,7 +268,7 @@ class UniquesListBase(FilterList[UniqueFilter], ABC):
Each unique filter subscribes to a subset of events to respond to.
"""
- def __init__(self, filtering_cog: "Filtering"):
+ def __init__(self, filtering_cog: Filtering):
super().__init__()
self.filtering_cog = filtering_cog
self.loaded_types: dict[str, type[UniqueFilter]] = {}
diff --git a/bot/exts/filtering/_ui/filter.py b/bot/exts/filtering/_ui/filter.py
index d15a3cacb..8108d01c0 100644
--- a/bot/exts/filtering/_ui/filter.py
+++ b/bot/exts/filtering/_ui/filter.py
@@ -293,7 +293,7 @@ class FilterEditView(EditBaseView):
if setting_name:
# Find the right dictionary to update.
if "/" in setting_name:
- filter_name, setting_name = setting_name.split("/", maxsplit=1)
+ _filter_name, setting_name = setting_name.split("/", maxsplit=1)
dict_to_edit = self.filter_settings_overrides
default_value = self.filter_type.extra_fields_type().model_dump()[setting_name]
else:
diff --git a/bot/exts/filtering/_ui/search.py b/bot/exts/filtering/_ui/search.py
index d26fd9929..3962e6b08 100644
--- a/bot/exts/filtering/_ui/search.py
+++ b/bot/exts/filtering/_ui/search.py
@@ -114,7 +114,7 @@ def template_settings(
result = get_filter(filter_id, filter_lists)
if not result:
raise BadArgument(f"Could not find a filter with ID `{filter_id}`.")
- filter_, filter_list, list_type = result
+ filter_, _filter_list, _list_type = result
if filter_type and not isinstance(filter_, filter_type):
raise BadArgument(f"The filter with ID `{filter_id}` is not of type {filter_type.name!r}.")
@@ -256,7 +256,7 @@ class SearchEditView(EditBaseView):
return
if "/" in setting_name:
- filter_name, setting_name = setting_name.split("/", maxsplit=1)
+ _filter_name, setting_name = setting_name.split("/", maxsplit=1)
dict_to_edit = self.filter_settings
else:
dict_to_edit = self.settings
diff --git a/bot/exts/filtering/_ui/ui.py b/bot/exts/filtering/_ui/ui.py
index 8d96a3521..12af3104f 100644
--- a/bot/exts/filtering/_ui/ui.py
+++ b/bot/exts/filtering/_ui/ui.py
@@ -136,7 +136,7 @@ def populate_embed_from_dict(embed: Embed, data: dict) -> None:
embed.add_field(name=setting, value=value, inline=len(value) < MAX_INLINE_SIZE)
-def parse_value(value: str, type_: type[T]) -> T:
+def parse_value[T](value: str, type_: type[T]) -> T:
"""Parse the value provided in the CLI and attempt to convert it to the provided type."""
blank = value == '""'
type_ = normalize_type(type_, prioritize_nonetype=blank)
diff --git a/bot/exts/filtering/_utils.py b/bot/exts/filtering/_utils.py
index 73974881a..92c244024 100644
--- a/bot/exts/filtering/_utils.py
+++ b/bot/exts/filtering/_utils.py
@@ -34,7 +34,7 @@ T = TypeVar("T")
Serializable = bool | int | float | str | list | dict | None
-def subclasses_in_package(package: str, prefix: str, parent: T) -> set[T]:
+def subclasses_in_package[T](package: str, prefix: str, parent: T) -> set[T]:
"""Return all the subclasses of class `parent`, found in the top-level of `package`, given by absolute path."""
subclasses = set()
@@ -157,7 +157,7 @@ def normalize_type(type_: type, *, prioritize_nonetype: bool = True) -> type:
return type_
-def starting_value(type_: type[T]) -> T:
+def starting_value[T](type_: type[T]) -> T:
"""Return a value of the given type."""
type_ = normalize_type(type_)
try:
diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py
index 6d2660175..1e55b2d79 100644
--- a/bot/exts/recruitment/talentpool/_cog.py
+++ b/bot/exts/recruitment/talentpool/_cog.py
@@ -41,7 +41,7 @@ class NominationContextModal(discord.ui.Modal, title="New Nomination"):
max_length=REASON_MAX_CHARS - 110
)
- def __init__(self, cog: "TalentPool", message: discord.Message, noms_channel: discord.TextChannel):
+ def __init__(self, cog: TalentPool, message: discord.Message, noms_channel: discord.TextChannel):
self.message = message
self.api = cog.api
self.noms_channel = noms_channel
diff --git a/bot/exts/utils/reminders.py b/bot/exts/utils/reminders.py
index 934798b96..93a695d46 100644
--- a/bot/exts/utils/reminders.py
+++ b/bot/exts/utils/reminders.py
@@ -82,7 +82,7 @@ class ModifyReminderConfirmationView(discord.ui.View):
class OptInReminderMentionView(discord.ui.View):
"""A button to opt-in to get notified of someone else's reminder."""
- def __init__(self, cog: "Reminders", reminder: dict, expiration: Duration):
+ def __init__(self, cog: Reminders, reminder: dict, expiration: Duration):
super().__init__()
self.cog = cog
diff --git a/bot/utils/function.py b/bot/utils/function.py
index 1ca973790..e77ed794e 100644
--- a/bot/utils/function.py
+++ b/bot/utils/function.py
@@ -34,7 +34,7 @@ def get_arg_value(name_or_pos: Argument, arguments: BoundArgs) -> t.Any:
arg_pos = name_or_pos
try:
- name, value = arg_values[arg_pos]
+ _name, value = arg_values[arg_pos]
return value
except IndexError:
raise ValueError(f"Argument position {arg_pos} is out of bounds.")
diff --git a/tests/bot/exts/moderation/test_incidents.py b/tests/bot/exts/moderation/test_incidents.py
index 444bb1142..239240251 100644
--- a/tests/bot/exts/moderation/test_incidents.py
+++ b/tests/bot/exts/moderation/test_incidents.py
@@ -112,7 +112,7 @@ class TestMakeEmbed(unittest.IsolatedAsyncioTestCase):
async def test_make_embed_actioned(self):
"""Embed is coloured green and footer contains 'Actioned' when `outcome=Signal.ACTIONED`."""
- embed, file = await incidents.make_embed(
+ embed, _file = await incidents.make_embed(
incident=MockMessage(created_at=CURRENT_TIME),
outcome=incidents.Signal.ACTIONED,
actioned_by=MockMember()
@@ -123,7 +123,7 @@ class TestMakeEmbed(unittest.IsolatedAsyncioTestCase):
async def test_make_embed_not_actioned(self):
"""Embed is coloured red and footer contains 'Rejected' when `outcome=Signal.NOT_ACTIONED`."""
- embed, file = await incidents.make_embed(
+ embed, _file = await incidents.make_embed(
incident=MockMessage(created_at=CURRENT_TIME),
outcome=incidents.Signal.NOT_ACTIONED,
actioned_by=MockMember()
@@ -139,7 +139,7 @@ class TestMakeEmbed(unittest.IsolatedAsyncioTestCase):
reported_timestamp = discord_timestamp(CURRENT_TIME)
relative_timestamp = discord_timestamp(CURRENT_TIME, TimestampFormats.RELATIVE)
- embed, file = await incidents.make_embed(incident, incidents.Signal.ACTIONED, MockMember())
+ embed, _file = await incidents.make_embed(incident, incidents.Signal.ACTIONED, MockMember())
self.assertEqual(
f"{incident.content}\n\n*Reported {reported_timestamp} ({relative_timestamp}).*",
@@ -808,7 +808,7 @@ class TestMessageLinkEmbeds(TestIncidents):
tests = {
"thisisasingleword"*10: "thisisasinglewordthisisasinglewordthisisasinglewor...",
- "\n".join("Lets make a new line test".split()): "Lets\nmake\na...",
+ "\n".join(["Lets", "make", "a", "new", "line", "test"]): "Lets\nmake\na...",
"Hello, World!" * 300: (
"Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!Hello, World!"
diff --git a/tests/bot/utils/test_messages.py b/tests/bot/utils/test_messages.py
index 9c22c9751..48a62ed1c 100644
--- a/tests/bot/utils/test_messages.py
+++ b/tests/bot/utils/test_messages.py
@@ -9,7 +9,8 @@ class TestMessages(unittest.TestCase):
def test_sub_clyde(self):
"""Uppercase E's and lowercase e's are substituted with their cyrillic counterparts."""
sub_e = "\u0435"
- sub_E = "\u0415" # noqa: N806: Uppercase E in variable name
+ # N806 fires for upper-case E in variable name.
+ sub_E = "\u0415" # noqa: N806
test_cases = (
(None, None),