Skip to content

Commit fc25610

Browse files
committed
Merge branch 'renovate/lock-file-maintenance-pep621' into bump-pycord
# Conflicts: # uv.lock
2 parents 43faf6d + cf17f0e commit fc25610

11 files changed

Lines changed: 415 additions & 397 deletions

‎.github/workflows/check-build-deploy.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
pre-commit-PUSH: # yamllint disable-line rule:key-ordering
130130
if: github.event_name == 'push'
131131
name: Verify pre-commit hooks (push)
132-
uses: ./.github/workflows/autofix-pre-commit.yaml
132+
uses: $/.github/workflows/autofix-pre-commit.yaml
133133
with:
134134
skip-autofix: true
135135

‎.pre-commit-config.yaml‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ default_stages: [pre-commit, pre-merge-commit, manual]
55

66
repos:
77
- repo: https://github.com/astral-sh/uv-pre-commit
8-
rev: 0.11.29
8+
rev: 0.12.13
99
hooks:
1010
- id: uv-lock
1111
always_run: true
@@ -21,7 +21,7 @@ repos:
2121
- id: codespell
2222

2323
- repo: https://github.com/tombi-toml/tombi-pre-commit
24-
rev: v1.2.0
24+
rev: v1.5.4
2525
hooks:
2626
- exclude: \A.+\.lock\Z
2727
id: tombi-format
@@ -32,15 +32,14 @@ repos:
3232
hooks:
3333
- id: sync-with-uv
3434

35-
- repo: https://github.com/rhysd/actionlint
36-
rev: v1.7.12
35+
- repo: https://github.com/kjanat/actionlint
36+
rev: v1.16
3737
hooks:
38-
- id: actionlint
39-
additional_dependencies: [github.com/wasilibs/go-shellcheck/cmd/shellcheck@latest] # yamllint disable-line rule:key-ordering
38+
- id: actionlint-shellcheck
4039
args: [-pyflakes=]
4140

4241
- repo: https://github.com/zizmorcore/zizmor-pre-commit
43-
rev: v1.27.0
42+
rev: v1.30.1
4443
hooks:
4544
- id: zizmor
4645
args: [--no-progress, --fix, --persona=auditor]
@@ -52,7 +51,7 @@ repos:
5251
args: [fix, --no-backup]
5352

5453
- repo: https://github.com/hadolint/hadolint
55-
rev: v2.14.0
54+
rev: v2.15.1
5655
hooks:
5756
- id: hadolint-docker
5857

@@ -63,14 +62,14 @@ repos:
6362
args: [--strict]
6463

6564
- repo: https://github.com/renovatebot/pre-commit-hooks
66-
rev: 43.265.3
65+
rev: 44.82.0
6766
hooks:
6867
- id: renovate-config-validator
6968
args: [--strict]
7069
stages: [manual]
7170

7271
- repo: https://github.com/python-jsonschema/check-jsonschema
73-
rev: 0.37.4
72+
rev: 0.38.0
7473
hooks:
7574
- id: check-jsonschema
7675
args: [--schemafile, 'https://json.schemastore.org/yamllint.json'] # yamllint disable-line rule:quoted-strings
@@ -114,7 +113,6 @@ repos:
114113
args: [--fix=lf]
115114
- id: detect-private-key
116115
- id: fix-byte-order-marker
117-
args: [-h]
118116

119117
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
120118
rev: v2.16.0
@@ -123,7 +121,7 @@ repos:
123121
args: [--autofix]
124122

125123
- repo: https://github.com/astral-sh/ruff-pre-commit
126-
rev: v0.15.22
124+
rev: v0.16.7
127125
hooks:
128126
- id: ruff-check
129127
args: [--fix]

‎cogs/command_error.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,28 @@ async def on_application_command_error(
7272
if isinstance(error, discord.ApplicationCommandInvokeError) and isinstance(
7373
error.original, GuildDoesNotExistError
7474
):
75-
command_name: str = (
75+
command_name: str | None = (
7676
ctx.command.callback.__name__
7777
if (
7878
ctx.command
7979
and hasattr(ctx.command, "callback")
8080
and not ctx.command.callback.__name__.startswith("_")
8181
)
82-
else (ctx.command.qualified_name if ctx.command else "unknown")
82+
else (ctx.command.qualified_name if ctx.command else None)
8383
)
8484
logger.critical(
8585
" ".join(
8686
message_part
8787
for message_part in (
8888
error.original.ERROR_CODE,
89-
f"({command_name})" if command_name in self.ERROR_ACTIVITIES else "",
89+
(
90+
f"({command_name})"
91+
if (
92+
command_name is not None
93+
and command_name in self.ERROR_ACTIVITIES
94+
)
95+
else ""
96+
),
9097
str(error.original).rstrip(".:"),
9198
)
9299
if message_part

‎cogs/kill.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
class ConfirmKillView(View):
2626
"""A discord.View containing two buttons to confirm shutting down TeX-Bot."""
2727

28-
@discord.ui.button( # type: ignore[arg-type]
28+
@discord.ui.button(
2929
label="SHUTDOWN", style=discord.ButtonStyle.red, custom_id="shutdown_confirm"
3030
)
3131
async def confirm_shutdown_button_callback(
32-
self, _: discord.Button, interaction: discord.Interaction
32+
self, _: discord.ui.Button["ConfirmKillView"], interaction: discord.Interaction
3333
) -> None:
3434
"""When the shutdown button is pressed, delete the message."""
3535
logger.debug('"Confirm" button pressed. %s', interaction)
3636

37-
@discord.ui.button( # type: ignore[arg-type]
37+
@discord.ui.button(
3838
label="CANCEL", style=discord.ButtonStyle.grey, custom_id="shutdown_cancel"
3939
)
4040
async def cancel_shutdown_button_callback(
41-
self, _: discord.Button, interaction: discord.Interaction
41+
self, _: discord.ui.Button["ConfirmKillView"], interaction: discord.Interaction
4242
) -> None:
4343
"""When the cancel button is pressed, delete the message."""
4444
logger.debug('"Cancel" button pressed. %s', interaction)

‎cogs/remind_me.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,16 @@ async def remind_me(
210210
211211
The "remind_me" command responds with the given message after the specified time.
212212
"""
213-
parsed_time: tuple[time.struct_time, int] = parsedatetime.Calendar().parseDT(
214-
delay, tzinfo=timezone.get_current_timezone()
215-
)
216213
if not ctx.channel:
217214
await self.command_send_error(
218215
ctx, message="This command can only be used in channels."
219216
)
220217
return
221218

219+
parsed_time: tuple[time.struct_time, int] = parsedatetime.Calendar().parseDT(
220+
delay, tzinfo=timezone.get_current_timezone()
221+
)
222+
222223
if parsed_time[1] == 0:
223224
await self.command_send_error(
224225
ctx,
@@ -311,7 +312,7 @@ async def clear_reminders_backlog(self) -> None:
311312
)
312313
if time_since_reminder_needed_to_be_sent > datetime.timedelta(minutes=15):
313314
user: discord.User | None = await self.bot.get_or_fetch(
314-
object_type=discord.User, object_id=int(reminder.discord_member.discord_id)
315+
discord.User, int(reminder.discord_member.discord_id)
315316
)
316317

317318
if not user:

‎cogs/send_introduction_reminders.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,18 @@ async def send_error(
227227
logging_message=logging_message,
228228
)
229229

230-
@ui.button( # type: ignore[arg-type]
230+
@ui.button(
231231
label="Opt-out of introduction reminders",
232232
custom_id="opt_out_introduction_reminders_button",
233233
style=discord.ButtonStyle.red,
234234
emoji=discord.PartialEmoji.from_str(emoji.emojize(":no_good:", language="alias")),
235235
)
236236
async def opt_out_introduction_reminders_button_callback(
237-
self, button: discord.Button, interaction: discord.Interaction
237+
self,
238+
button: discord.ui.Button[
239+
"SendIntroductionRemindersTaskCog.OptOutIntroductionRemindersView"
240+
],
241+
interaction: discord.Interaction,
238242
) -> None:
239243
"""
240244
Set the opt-in/out flag depending on the status of the button.

‎cogs/stats/__init__.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ async def channel_stats(
9090
ctx.channel, (discord.CategoryChannel, discord.ForumChannel)
9191
):
9292
await self.command_send_error(
93-
ctx, message="This command can only be used in text channels."
93+
ctx, message="This command cannot be used in category/forum channels."
9494
)
9595
return
9696

@@ -169,7 +169,7 @@ async def server_stats(self, ctx: "TeXBotApplicationContext") -> None:
169169
ctx.channel, (discord.CategoryChannel, discord.ForumChannel)
170170
):
171171
await self.command_send_error(
172-
ctx, message="This command can only be used in text channels."
172+
ctx, message="This command cannot be used in category/forum channels."
173173
)
174174
return
175175

@@ -257,7 +257,7 @@ async def user_stats(self, ctx: "TeXBotApplicationContext") -> None:
257257
ctx.channel, (discord.CategoryChannel, discord.ForumChannel)
258258
):
259259
await self.command_send_error(
260-
ctx, message="This command can only be used in text channels."
260+
ctx, message="This command cannot be used in category/forum channels."
261261
)
262262
return
263263

@@ -342,7 +342,7 @@ async def left_member_stats(self, ctx: "TeXBotApplicationContext") -> None:
342342
ctx.channel, (discord.CategoryChannel, discord.ForumChannel)
343343
):
344344
await self.command_send_error(
345-
ctx, message="This command can only be used in text channels."
345+
ctx, message="This command cannot be used in category/forum channels."
346346
)
347347
return
348348

‎cogs/strike.py‎

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ async def perform_moderation_action(
9191
class ConfirmStrikeMemberView(View):
9292
"""A discord.View containing two buttons to confirm giving the member a strike."""
9393

94-
@discord.ui.button( # type: ignore[arg-type]
94+
@discord.ui.button(
9595
label="Yes", style=discord.ButtonStyle.red, custom_id="yes_strike_member"
9696
)
9797
async def yes_strike_member_button_callback(
98-
self, _: discord.Button, interaction: discord.Interaction
98+
self, _: discord.ui.Button["ConfirmStrikeMemberView"], interaction: discord.Interaction
9999
) -> None:
100100
"""
101101
Delete the message associated with the view when the Yes button is pressed.
@@ -110,11 +110,11 @@ async def yes_strike_member_button_callback(
110110
view=None
111111
) # NOTE: Despite removing the view within the normal command processing loop, the view also needs to be removed here to prevent an Unknown Webhook error
112112

113-
@discord.ui.button( # type: ignore[arg-type]
113+
@discord.ui.button(
114114
label="No", style=discord.ButtonStyle.grey, custom_id="no_strike_member"
115115
)
116116
async def no_strike_member_button_callback(
117-
self, _: discord.Button, interaction: discord.Interaction
117+
self, _: discord.ui.Button["ConfirmStrikeMemberView"], interaction: discord.Interaction
118118
) -> None:
119119
"""
120120
Delete the message associated with the view when the No button is pressed.
@@ -133,11 +133,13 @@ async def no_strike_member_button_callback(
133133
class ConfirmManualModerationView(View):
134134
"""A discord.View to confirm manually applying a moderation action."""
135135

136-
@discord.ui.button( # type: ignore[arg-type]
136+
@discord.ui.button(
137137
label="Yes", style=discord.ButtonStyle.red, custom_id="yes_manual_moderation_action"
138138
)
139139
async def yes_manual_moderation_action_button_callback(
140-
self, _: discord.Button, interaction: discord.Interaction
140+
self,
141+
_: discord.ui.Button["ConfirmManualModerationView"],
142+
interaction: discord.Interaction,
141143
) -> None:
142144
"""
143145
Delete the message associated with the view when the Yes button is pressed.
@@ -153,11 +155,13 @@ async def yes_manual_moderation_action_button_callback(
153155
view=None
154156
) # NOTE: Despite removing the view within the normal command processing loop, the view also needs to be removed here to prevent an Unknown Webhook error
155157

156-
@discord.ui.button( # type: ignore[arg-type]
158+
@discord.ui.button(
157159
label="No", style=discord.ButtonStyle.grey, custom_id="no_manual_moderation_action"
158160
)
159161
async def no_manual_moderation_action_button_callback(
160-
self, _: discord.Button, interaction: discord.Interaction
162+
self,
163+
_: discord.ui.Button["ConfirmManualModerationView"],
164+
interaction: discord.Interaction,
161165
) -> None:
162166
"""
163167
Delete the message associated with the view when the No button is pressed.
@@ -177,11 +181,13 @@ async def no_manual_moderation_action_button_callback(
177181
class ConfirmStrikesOutOfSyncWithBanView(View):
178182
"""A discord.View containing two buttons to confirm banning a member with > 3 strikes."""
179183

180-
@discord.ui.button( # type: ignore[arg-type]
184+
@discord.ui.button(
181185
label="Yes", style=discord.ButtonStyle.red, custom_id="yes_out_of_sync_ban_member"
182186
)
183187
async def yes_out_of_sync_ban_member_button_callback(
184-
self, _: discord.Button, interaction: discord.Interaction
188+
self,
189+
_: discord.ui.Button["ConfirmStrikesOutOfSyncWithBanView"],
190+
interaction: discord.Interaction,
185191
) -> None:
186192
"""
187193
Delete the message associated with the view when the Yes button is pressed.
@@ -197,11 +203,13 @@ async def yes_out_of_sync_ban_member_button_callback(
197203
view=None
198204
) # NOTE: Despite removing the view within the normal command processing loop, the view also needs to be removed here to prevent an Unknown Webhook error
199205

200-
@discord.ui.button( # type: ignore[arg-type]
206+
@discord.ui.button(
201207
label="No", style=discord.ButtonStyle.grey, custom_id="no_out_of_sync_ban_member"
202208
)
203209
async def no_out_of_sync_ban_member_button_callback(
204-
self, _: discord.Button, interaction: discord.Interaction
210+
self,
211+
_: discord.ui.Button["ConfirmStrikesOutOfSyncWithBanView"],
212+
interaction: discord.Interaction,
205213
) -> None:
206214
"""
207215
Delete the message associated with the view when the No button is pressed.
@@ -229,7 +237,7 @@ class BaseStrikeCog(TeXBotBaseCog):
229237
SUGGESTED_ACTIONS: "Final[Mapping[int, str]]" = {1: "time-out", 2: "kick", 3: "ban"} # noqa: RUF012
230238

231239
async def _send_strike_user_message(
232-
self, strike_user: discord.User | discord.Member, member_strikes: DiscordMemberStrikes
240+
self, strike_user: discord.abc.Messageable, member_strikes: DiscordMemberStrikes
233241
) -> None:
234242
try:
235243
await strike_user.send(
@@ -322,7 +330,7 @@ async def _confirm_increase_strike(
322330
*,
323331
perform_action: bool,
324332
) -> None:
325-
if perform_action and isinstance(strike_user, discord.User):
333+
if perform_action and not isinstance(strike_user, discord.Member):
326334
STRIKE_USER_TYPE_ERROR_MESSAGE: Final[str] = (
327335
"Cannot perform moderation action on non-guild member."
328336
)
@@ -459,9 +467,9 @@ async def get_confirmation_message_channel(
459467
) from fetch_log_channel_error
460468

461469
raw_user: discord.User | None = (
462-
await self.bot.get_or_fetch(discord.User, user.id)
463-
if isinstance(user, discord.Member)
464-
else user
470+
user
471+
if isinstance(user, discord.User)
472+
else await self.bot.get_or_fetch(discord.User, user.id)
465473
)
466474
if not raw_user:
467475
raise StrikeTrackingError
@@ -512,9 +520,12 @@ async def _confirm_manual_add_strike( # noqa: PLR0915
512520
async for _audit_log_entry in main_guild.audit_logs(
513521
after=discord.utils.utcnow() - datetime.timedelta(minutes=1), action=action
514522
)
515-
if _audit_log_entry.target
516-
and _audit_log_entry.target.id
517-
== strike_user.id # NOTE: IDs are checked here rather than the objects themselves as the audit log provides an unusual object type in some cases.
523+
if (
524+
_audit_log_entry.target
525+
and (
526+
_audit_log_entry.target.id == strike_user.id
527+
) # NOTE: IDs are checked here rather than the objects themselves as the audit log provides an unusual object type in some cases.
528+
)
518529
)
519530
except (StopIteration, StopAsyncIteration):
520531
logger.debug("Printing 5 most recent audit logs:")
@@ -761,15 +772,14 @@ async def on_member_update(self, before: discord.Member, after: discord.Member)
761772

762773
audit_log_entry: discord.AuditLogEntry
763774
async for audit_log_entry in main_guild.audit_logs(limit=5):
764-
FOUND_CORRECT_AUDIT_LOG_ENTRY: bool = (
765-
(audit_log_entry.target is not None)
775+
if (
776+
audit_log_entry.target
766777
and (audit_log_entry.target.id == after.id)
767778
and (
768779
audit_log_entry.action
769780
== discord.AuditLogAction.auto_moderation_user_communication_disabled
770781
)
771-
)
772-
if FOUND_CORRECT_AUDIT_LOG_ENTRY:
782+
):
773783
await self._confirm_manual_add_strike(
774784
strike_user=after, action=audit_log_entry.action
775785
)

0 commit comments

Comments
 (0)