Skip to content

Commit d42ae11

Browse files
[autofix.ci] apply automated fixes
1 parent fc10d97 commit d42ae11

22 files changed

Lines changed: 456 additions & 207 deletions

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ repos:
116116
args: [--autofix]
117117

118118
- repo: https://github.com/astral-sh/ruff-pre-commit
119-
rev: v0.15.13
119+
rev: v0.15.14
120120
hooks:
121121
- id: ruff-check
122122
args: [--fix]

‎cogs/archive.py‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,18 @@ async def autocomplete_get_non_archival_categories(
5959
)
6060
}
6161

62-
async def _set_permissions(self, channel: AllChannelTypes, ctx: TeXBotApplicationContext, interaction_member: discord.Member, *, committee_role: discord.Role, guest_role: discord.Role, member_role: discord.Role, archivist_role: discord.Role, everyone_role: discord.Role) -> None: # noqa: PLR0913,E501
62+
async def _set_permissions(
63+
self,
64+
channel: AllChannelTypes,
65+
ctx: TeXBotApplicationContext,
66+
interaction_member: discord.Member,
67+
*,
68+
committee_role: discord.Role,
69+
guest_role: discord.Role,
70+
member_role: discord.Role,
71+
archivist_role: discord.Role,
72+
everyone_role: discord.Role,
73+
) -> None: # noqa: PLR0913,E501
6374
CHANNEL_NEEDS_COMMITTEE_ARCHIVING: Final[bool] = bool(
6475
channel.permissions_for(committee_role).is_superset(
6576
discord.Permissions(view_channel=True),
@@ -71,23 +82,23 @@ async def _set_permissions(self, channel: AllChannelTypes, ctx: TeXBotApplicatio
7182
if CHANNEL_NEEDS_COMMITTEE_ARCHIVING:
7283
await channel.set_permissions(
7384
everyone_role,
74-
reason=f"{interaction_member.display_name} used \"/archive\".",
85+
reason=f'{interaction_member.display_name} used "/archive".',
7586
view_channel=False,
7687
)
7788
await channel.set_permissions(
7889
guest_role,
7990
overwrite=None,
80-
reason=f"{interaction_member.display_name} used \"/archive\".",
91+
reason=f'{interaction_member.display_name} used "/archive".',
8192
)
8293
await channel.set_permissions(
8394
member_role,
8495
overwrite=None,
85-
reason=f"{interaction_member.display_name} used \"/archive\".",
96+
reason=f'{interaction_member.display_name} used "/archive".',
8697
)
8798
await channel.set_permissions(
8899
committee_role,
89100
overwrite=None,
90-
reason=f"{interaction_member.display_name} used \"/archive\".",
101+
reason=f'{interaction_member.display_name} used "/archive".',
91102
)
92103
return
93104

@@ -99,27 +110,27 @@ async def _set_permissions(self, channel: AllChannelTypes, ctx: TeXBotApplicatio
99110
if CHANNEL_NEEDS_NORMAL_ARCHIVING:
100111
await channel.set_permissions(
101112
everyone_role,
102-
reason=f"{interaction_member.display_name} used \"/archive\".",
113+
reason=f'{interaction_member.display_name} used "/archive".',
103114
view_channel=False,
104115
)
105116
await channel.set_permissions(
106117
guest_role,
107118
overwrite=None,
108-
reason=f"{interaction_member.display_name} used \"/archive\".",
119+
reason=f'{interaction_member.display_name} used "/archive".',
109120
)
110121
await channel.set_permissions(
111122
member_role,
112123
overwrite=None,
113-
reason=f"{interaction_member.display_name} used \"/archive\".",
124+
reason=f'{interaction_member.display_name} used "/archive".',
114125
)
115126
await channel.set_permissions(
116127
committee_role,
117-
reason=f"{interaction_member.display_name} used \"/archive\".",
128+
reason=f'{interaction_member.display_name} used "/archive".',
118129
view_channel=False,
119130
)
120131
await channel.set_permissions(
121132
archivist_role,
122-
reason=f"{interaction_member.display_name} used \"/archive\".",
133+
reason=f'{interaction_member.display_name} used "/archive".',
123134
view_channel=True,
124135
)
125136
return

‎cogs/change_config.py‎

Lines changed: 97 additions & 74 deletions
Large diffs are not rendered by default.

‎cogs/command_error.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ class CommandErrorCog(TeXBotBaseCog):
3333
"""Cog class that defines additional code to execute upon a command error."""
3434

3535
@classmethod
36-
def _get_logging_message_from_error(cls, error: discord.ApplicationCommandInvokeError) -> str | None: # noqa: E501
36+
def _get_logging_message_from_error(
37+
cls, error: discord.ApplicationCommandInvokeError
38+
) -> str | None: # noqa: E501
3739
if isinstance(error.original, GuildDoesNotExistError):
3840
return None
3941

4042
if not str(error.original).strip(". -\"'"):
4143
return f"{error.original.__class__.__name__} was raised."
4244

43-
if str(error.original).startswith("\"") or str(error.original).startswith("'"):
45+
if str(error.original).startswith('"') or str(error.original).startswith("'"):
4446
return f"{error.original.__class__.__name__}: {error.original}"
4547

4648
if isinstance(error.original, UnknownDjangoError):

‎cogs/make_member.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ async def make_member(
118118
await self.command_send_error(
119119
ctx,
120120
message=(
121-
f"{group_member_id!r} is not a valid "
122-
f"{self.bot.group_member_id_type} ID."
121+
f"{group_member_id!r} is not a valid {self.bot.group_member_id_type} ID."
123122
),
124123
)
125124
return

‎cogs/send_introduction_reminders.py‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ async def on_ready(self) -> None:
7373
self.bot.add_view(self.OptOutIntroductionRemindersView(self.bot))
7474

7575
@classmethod
76-
async def _check_if_member_needs_reminder(cls, member_id: int, member_joined_at: datetime.datetime) -> bool: # noqa: E501
76+
async def _check_if_member_needs_reminder(
77+
cls, member_id: int, member_joined_at: datetime.datetime
78+
) -> bool: # noqa: E501
7779
MEMBER_NEEDS_ONE_OFF_REMINDER: Final[bool] = (
7880
settings["SEND_INTRODUCTION_REMINDERS_ENABLED"] == "once"
7981
and not await (
@@ -85,9 +87,9 @@ async def _check_if_member_needs_reminder(cls, member_id: int, member_joined_at:
8587
MEMBER_NEEDS_RECURRING_REMINDER: Final[bool] = (
8688
settings["SEND_INTRODUCTION_REMINDERS_ENABLED"] == "interval"
8789
)
88-
MEMBER_RECENTLY_JOINED: bool = (
89-
discord.utils.utcnow() - member_joined_at
90-
) <= settings["SEND_INTRODUCTION_REMINDERS_DELAY"]
90+
MEMBER_RECENTLY_JOINED: bool = (discord.utils.utcnow() - member_joined_at) <= settings[
91+
"SEND_INTRODUCTION_REMINDERS_DELAY"
92+
]
9193
MEMBER_OPTED_OUT_FROM_REMINDERS: Final[bool] = await (
9294
await IntroductionReminderOptOutMember.objects.afilter(
9395
discord_id=member_id,
@@ -303,10 +305,13 @@ async def opt_out_introduction_reminders_button_callback( # type: ignore[misc]
303305
)
304306
except ValidationError as create_introduction_reminder_opt_out_member_error:
305307
ERROR_IS_ALREADY_EXISTS: Final[bool] = bool(
306-
"hashed_member_id" in create_introduction_reminder_opt_out_member_error.message_dict # noqa: E501
308+
"hashed_member_id"
309+
in create_introduction_reminder_opt_out_member_error.message_dict # noqa: E501
307310
and any(
308311
"already exists" in error
309-
for error in create_introduction_reminder_opt_out_member_error.message_dict["hashed_member_id"] # noqa: E501
312+
for error in create_introduction_reminder_opt_out_member_error.message_dict[
313+
"hashed_member_id"
314+
] # noqa: E501
310315
) # noqa: COM812
311316
)
312317
if not ERROR_IS_ALREADY_EXISTS:

‎cogs/startup.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def _setup_discord_log_channel(self) -> None:
6161
new_discord_logging_handler: DiscordHandler = DiscordHandler(
6262
(
6363
existing_discord_logging_handler.name
64-
if existing_discord_logging_handler.name != DEFAULT_DISCORD_LOGGING_HANDLER_DISPLAY_NAME # noqa: E501
64+
if existing_discord_logging_handler.name
65+
!= DEFAULT_DISCORD_LOGGING_HANDLER_DISPLAY_NAME # noqa: E501
6566
else (
6667
self.bot.user.name
6768
if self.bot.user
@@ -86,7 +87,10 @@ def _setup_discord_log_channel(self) -> None:
8687
else:
8788
logger.warning(NO_DISCORD_LOG_CHANNEL_SET_MESSAGE)
8889

89-
elif len(discord_logging_handlers) == 0 or not settings["DISCORD_LOG_CHANNEL_WEBHOOK_URL"]: # noqa: E501
90+
elif (
91+
len(discord_logging_handlers) == 0
92+
or not settings["DISCORD_LOG_CHANNEL_WEBHOOK_URL"]
93+
): # noqa: E501
9094
logger.warning(NO_DISCORD_LOG_CHANNEL_SET_MESSAGE)
9195

9296
else:
@@ -134,11 +138,11 @@ async def _check_strike_performed_manually_warning_location_exists(self) -> None
134138
repr(settings["STRIKE_PERFORMED_MANUALLY_WARNING_LOCATION"]),
135139
)
136140

137-
strike_performed_manually_warning_location_similar_to_dm: bool = (
138-
settings["STRIKE_PERFORMED_MANUALLY_WARNING_LOCATION"].lower() in (
139-
"dm",
140-
"dms",
141-
)
141+
strike_performed_manually_warning_location_similar_to_dm: bool = settings[
142+
"STRIKE_PERFORMED_MANUALLY_WARNING_LOCATION"
143+
].lower() in (
144+
"dm",
145+
"dms",
142146
)
143147
if strike_performed_manually_warning_location_similar_to_dm:
144148
logger.info(

‎config/__init__.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def view_single_config_setting_value(config_setting_name: str) -> str | None:
178178
return settings._public_view_single_raw_value(config_setting_name=config_setting_name) # noqa: SLF001
179179

180180

181-
async def assign_single_config_setting_value(config_setting_name: str, new_config_setting_value: str) -> None: # noqa: E501
181+
async def assign_single_config_setting_value(
182+
config_setting_name: str, new_config_setting_value: str
183+
) -> None: # noqa: E501
182184
# noinspection GrazieInspection
183185
"""Set the value of a single configuration setting within settings tree hierarchy."""
184186
# noinspection PyProtectedMember

‎config/_messages/__init__.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def __getattr__(self, item: str) -> Any: # type: ignore[misc] # noqa: ANN401
2727
f"{type(self).__name__!r} object has no attribute {item!r}"
2828
)
2929

30-
if "_pytest" in item or item in ("__bases__", "__test__"): # NOTE: Overriding __getattr__() leads to many edge-case issues where external libraries will attempt to call getattr() with peculiar values
30+
if (
31+
"_pytest" in item or item in ("__bases__", "__test__")
32+
): # NOTE: Overriding __getattr__() leads to many edge-case issues where external libraries will attempt to call getattr() with peculiar values
3133
raise AttributeError(MISSING_ATTRIBUTE_MESSAGE)
3234

3335
IN_MESSAGE_KEY_FORMAT: Final[bool] = bool(
@@ -52,8 +54,11 @@ def __getitem__(self, item: str) -> Any: # type: ignore[misc] # noqa: ANN401
5254
except AttributeError as attribute_not_exist_error:
5355
key_error_message: str = item
5456

55-
ERROR_WAS_FROM_INVALID_KEY_NAME: Final[bool] = self.format_invalid_message_id_message(item) in str( # noqa: E501
56-
attribute_not_exist_error,
57+
ERROR_WAS_FROM_INVALID_KEY_NAME: Final[bool] = (
58+
self.format_invalid_message_id_message(item)
59+
in str( # noqa: E501
60+
attribute_not_exist_error,
61+
)
5762
)
5863
if ERROR_WAS_FROM_INVALID_KEY_NAME:
5964
key_error_message = str(attribute_not_exist_error)
@@ -64,7 +69,7 @@ def __getitem__(self, item: str) -> Any: # type: ignore[misc] # noqa: ANN401
6469
async def _public_load(cls, messages_locale_code: str) -> None:
6570
if messages_locale_code not in MESSAGES_LOCALE_CODES:
6671
INVALID_MESSAGES_LOCALE_CODE_MESSAGE: Final[str] = (
67-
f"{"messages_locale_code"!r} must be one of "
72+
f"{'messages_locale_code'!r} must be one of "
6873
f"'{"', '".join(MESSAGES_LOCALE_CODES)}'"
6974
)
7075
raise ValueError(INVALID_MESSAGES_LOCALE_CODE_MESSAGE)

‎config/_messages/locales/en-GB.json‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2+
"opt-in-roles-selectors": [
3+
"_ _\nReact to this message to get pronoun roles\n:regional_indicator_h: - He/Him\n:regional_indicator_s: - She/Her\n:regional_indicator_t: - They/Them",
4+
"_ _\nReact to this message to get year group roles\n:zero: - Foundation Year\n:one: - First Year\n:two: - Second Year\n:regional_indicator_f: - Final Year (incl. 3rd Year MSci/MEng)\n:regional_indicator_i: - Year in Industry\n:regional_indicator_a: - Year Abroad\n:regional_indicator_t: - Post-Graduate Taught (Masters/MSc)\n:regional_indicator_r: - Post-Graduate Research (PhD)\n:regional_indicator_j: - Joint Honours\n:a: - Alumnus\n:regional_indicator_d: - Postdoc",
5+
"_ _\nReact to this message to join the **opt in channels**\n:speech_balloon: - Serious Talk\n:house_with_garden: - Housing\n:video_game: - Gaming\n:tv: - Anime\n:soccer: - Sport\n:briefcase: - Industry\n:pick: - Minecraft\n:technologist: - GitHub\n:bookmark: - Archivist\n:ramen: - Rate My Meal",
6+
"_ _\nReact to this message to **__opt out__** of the #starboard\n:no_entry_sign: - Messages you send **won't** be eligible to be added to the starboard, and stars you add to a message won't be counted towards the starboard threshold\n:star: - Your messages **can** be added to the starboard and stars you add to messages **will** be counted towards the starboard threshold",
7+
"_ _\nReact to this message to opt in to News notifications\n:speaker: - Get notifications when we `@News`\n:mute:- Don't get notifications when we `@News`\n\n> We will still use `@everyone` messages if there is something urgent"
8+
],
29
"welcome-messages": [
310
"<User> is the lisan al gaib. As it was written!",
411
"Welcome, <User>. We've been expecting you ( \u0361\u00b0 \u035c\u0296 \u0361\u00b0)",
@@ -50,12 +57,5 @@
5057
"The truth is <User>.... the game was rigged from the start.",
5158
"Did you ever hear the tragedy of Darth <User> the Wise? I thought not. It's not a story the lecturers would tell you.",
5259
"`<coroutine object BaseInductCog.get_random_welcome_message at 0x0000011EFD355120; user_object:`<User>`>`"
53-
],
54-
"opt-in-roles-selectors": [
55-
"_ _\nReact to this message to get pronoun roles\n:regional_indicator_h: - He/Him\n:regional_indicator_s: - She/Her\n:regional_indicator_t: - They/Them",
56-
"_ _\nReact to this message to get year group roles\n:zero: - Foundation Year\n:one: - First Year\n:two: - Second Year\n:regional_indicator_f: - Final Year (incl. 3rd Year MSci/MEng)\n:regional_indicator_i: - Year in Industry\n:regional_indicator_a: - Year Abroad\n:regional_indicator_t: - Post-Graduate Taught (Masters/MSc)\n:regional_indicator_r: - Post-Graduate Research (PhD)\n:regional_indicator_j: - Joint Honours\n:a: - Alumnus\n:regional_indicator_d: - Postdoc",
57-
"_ _\nReact to this message to join the **opt in channels**\n:speech_balloon: - Serious Talk\n:house_with_garden: - Housing\n:video_game: - Gaming\n:tv: - Anime\n:soccer: - Sport\n:briefcase: - Industry\n:pick: - Minecraft\n:technologist: - GitHub\n:bookmark: - Archivist\n:ramen: - Rate My Meal",
58-
"_ _\nReact to this message to **__opt out__** of the #starboard\n:no_entry_sign: - Messages you send **won't** be eligible to be added to the starboard, and stars you add to a message won't be counted towards the starboard threshold\n:star: - Your messages **can** be added to the starboard and stars you add to messages **will** be counted towards the starboard threshold",
59-
"_ _\nReact to this message to opt in to News notifications\n:speaker: - Get notifications when we `@News`\n:mute:- Don't get notifications when we `@News`\n\n> We will still use `@everyone` messages if there is something urgent"
6060
]
6161
}

0 commit comments

Comments
 (0)