Skip to content

Commit c16605d

Browse files
committed
Update ruff syntax
1 parent 4139132 commit c16605d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+287
-293
lines changed

cogs/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
from utils import TeXBot, TeXBotBaseCog
5353

54-
__all__: "Sequence[str]" = (
54+
__all__: Sequence[str] = (
5555
"AddUsersToThreadsAndChannelsCommandCog",
5656
"AnnualRolesResetCommandCog",
5757
"AnnualYearChannelsIncrementCommandCog",
@@ -91,7 +91,7 @@
9191
)
9292

9393

94-
def setup(bot: "TeXBot") -> None:
94+
def setup(bot: TeXBot) -> None:
9595
"""Add all the cogs to the bot, at bot startup."""
9696
cogs: Iterable[type[TeXBotBaseCog]] = (
9797
AddUsersToThreadsAndChannelsCommandsCog,

cogs/add_users_to_threads_and_channels.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
from utils import TeXBotApplicationContext, TeXBotAutocompleteContext
2121

2222

23-
__all__: "Sequence[str]" = ("AddUsersToThreadsAndChannelsCommandsCog",)
23+
__all__: Sequence[str] = ("AddUsersToThreadsAndChannelsCommandsCog",)
2424

2525

26-
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
26+
logger: Final[Logger] = logging.getLogger("TeX-Bot")
2727

2828

2929
class AddUsersToThreadsAndChannelsCommandsCog(TeXBotBaseCog):
3030
"""Cog for adding users to threads."""
3131

3232
@staticmethod
3333
async def autocomplete_get_members(
34-
ctx: "TeXBotAutocompleteContext",
35-
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
34+
ctx: TeXBotAutocompleteContext,
35+
) -> AbstractSet[discord.OptionChoice] | AbstractSet[str]:
3636
"""Autocomplete callable that generates the set of available selectable members."""
3737
try:
3838
main_guild: discord.Guild = ctx.bot.main_guild
@@ -58,8 +58,8 @@ async def autocomplete_get_members(
5858

5959
@staticmethod
6060
async def autocomplete_get_roles(
61-
ctx: "TeXBotAutocompleteContext",
62-
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
61+
ctx: TeXBotAutocompleteContext,
62+
) -> AbstractSet[discord.OptionChoice] | AbstractSet[str]:
6363
"""Autocomplete callable that generates the set of available selectable roles."""
6464
try:
6565
main_guild: discord.Guild = ctx.bot.main_guild
@@ -205,7 +205,7 @@ async def on_thread_create(self, thread: discord.Thread) -> None:
205205
@CommandChecks.check_interaction_user_in_main_guild
206206
async def add_user_to_channel(
207207
self,
208-
ctx: "TeXBotApplicationContext",
208+
ctx: TeXBotApplicationContext,
209209
user_id_str: str,
210210
silent: bool, # noqa: FBT001
211211
) -> None:
@@ -260,7 +260,7 @@ async def add_user_to_channel(
260260
@CommandChecks.check_interaction_user_in_main_guild
261261
async def add_role_to_channel(
262262
self,
263-
ctx: "TeXBotApplicationContext",
263+
ctx: TeXBotApplicationContext,
264264
role_id_str: str,
265265
silent: bool, # noqa: FBT001
266266
) -> None:

cogs/annual_handover_and_reset.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
from utils import AllChannelTypes, TeXBotApplicationContext
1919

20-
__all__: "Sequence[str]" = (
20+
__all__: Sequence[str] = (
2121
"AnnualRolesResetCommandCog",
2222
"AnnualYearChannelsIncrementCommandCog",
2323
"CommitteeHandoverCommandCog",
2424
)
2525

2626

27-
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
27+
logger: Final[Logger] = logging.getLogger("TeX-Bot")
2828

2929

3030
class CommitteeHandoverCommandCog(TeXBotBaseCog):
@@ -36,7 +36,7 @@ class CommitteeHandoverCommandCog(TeXBotBaseCog):
3636
)
3737
@CommandChecks.check_interaction_user_has_committee_role
3838
@CommandChecks.check_interaction_user_in_main_guild
39-
async def committee_handover(self, ctx: "TeXBotApplicationContext") -> None:
39+
async def committee_handover(self, ctx: TeXBotApplicationContext) -> None:
4040
"""
4141
Definition & callback response of the "committee_handover" command.
4242
@@ -165,7 +165,7 @@ async def committee_handover(self, ctx: "TeXBotApplicationContext") -> None:
165165
class AnnualRolesResetCommandCog(TeXBotBaseCog):
166166
"""Cog class that defines the "/annual-roles-reset" command."""
167167

168-
ACADEMIC_YEAR_ROLE_NAMES: "Final[frozenset[str]]" = frozenset(
168+
ACADEMIC_YEAR_ROLE_NAMES: Final[frozenset[str]] = frozenset(
169169
{
170170
"Foundation Year",
171171
"First Year",
@@ -184,7 +184,7 @@ class AnnualRolesResetCommandCog(TeXBotBaseCog):
184184
)
185185
@CommandChecks.check_interaction_user_has_committee_role
186186
@CommandChecks.check_interaction_user_in_main_guild
187-
async def annual_roles_reset(self, ctx: "TeXBotApplicationContext") -> None:
187+
async def annual_roles_reset(self, ctx: TeXBotApplicationContext) -> None:
188188
"""
189189
Definition & callback response of the "annual_roles_reset" command.
190190
@@ -273,7 +273,7 @@ class AnnualYearChannelsIncrementCommandCog(TeXBotBaseCog):
273273
)
274274
@CommandChecks.check_interaction_user_has_committee_role
275275
@CommandChecks.check_interaction_user_in_main_guild
276-
async def increment_year_channels(self, ctx: "TeXBotApplicationContext") -> None:
276+
async def increment_year_channels(self, ctx: TeXBotApplicationContext) -> None:
277277
"""
278278
Definition and callback response of the "increment_year_channels" command.
279279

cogs/archive.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818

1919
from utils import AllChannelTypes, TeXBotApplicationContext, TeXBotAutocompleteContext
2020

21-
__all__: "Sequence[str]" = ("ArchiveCommandsCog",)
21+
__all__: Sequence[str] = ("ArchiveCommandsCog",)
2222

2323

24-
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
24+
logger: Final[Logger] = logging.getLogger("TeX-Bot")
2525

2626

2727
class ArchiveCommandsCog(TeXBotBaseCog):
2828
"""Cog class that defines the "/archive" command and its call-back method."""
2929

3030
@staticmethod
3131
async def autocomplete_get_non_archival_categories(
32-
ctx: "TeXBotAutocompleteContext",
33-
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
32+
ctx: TeXBotAutocompleteContext,
33+
) -> AbstractSet[discord.OptionChoice] | AbstractSet[str]:
3434
"""
3535
Autocomplete callable that generates the set of available selectable categories.
3636
@@ -50,8 +50,8 @@ async def autocomplete_get_non_archival_categories(
5050

5151
@staticmethod
5252
async def autocomplete_get_archival_categories(
53-
ctx: "TeXBotAutocompleteContext",
54-
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
53+
ctx: TeXBotAutocompleteContext,
54+
) -> AbstractSet[discord.OptionChoice] | AbstractSet[str]:
5555
"""
5656
Autocomplete callable that generates the set of categories to hold archived channels.
5757
@@ -72,8 +72,8 @@ async def autocomplete_get_archival_categories(
7272

7373
@staticmethod
7474
async def autocomplete_get_non_archived_channels(
75-
ctx: "TeXBotAutocompleteContext",
76-
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
75+
ctx: TeXBotAutocompleteContext,
76+
) -> AbstractSet[discord.OptionChoice] | AbstractSet[str]:
7777
"""
7878
Autocomplete callable that generates the set of channels that the user can archive.
7979
@@ -123,7 +123,7 @@ async def autocomplete_get_non_archived_channels(
123123
@CommandChecks.check_interaction_user_in_main_guild
124124
async def archive_category(
125125
self,
126-
ctx: "TeXBotApplicationContext",
126+
ctx: TeXBotApplicationContext,
127127
str_category_id: str,
128128
allow_archivist: bool, # noqa: FBT001
129129
) -> None:
@@ -236,7 +236,7 @@ async def archive_category(
236236
@CommandChecks.check_interaction_user_has_committee_role
237237
@CommandChecks.check_interaction_user_in_main_guild
238238
async def archive_channel(
239-
self, ctx: "TeXBotApplicationContext", str_channel_id: str, str_category_id: str
239+
self, ctx: TeXBotApplicationContext, str_channel_id: str, str_category_id: str
240240
) -> None:
241241
"""
242242
Definition & callback response of the "archive-channel" command.

cogs/check_su_platform_authorisation.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,26 @@
2323

2424
from utils import TeXBot, TeXBotApplicationContext
2525

26-
__all__: "Sequence[str]" = (
26+
__all__: Sequence[str] = (
2727
"CheckSUPlatformAuthorisationCommandCog",
2828
"CheckSUPlatformAuthorisationTaskCog",
2929
)
3030

3131

32-
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
32+
logger: Final[Logger] = logging.getLogger("TeX-Bot")
3333

34-
REQUEST_HEADERS: "Final[Mapping[str, str]]" = {
34+
REQUEST_HEADERS: Final[Mapping[str, str]] = {
3535
"Cache-Control": "no-cache",
3636
"Pragma": "no-cache",
3737
"Expires": "0",
3838
}
3939

40-
REQUEST_COOKIES: "Final[Mapping[str, str]]" = {
40+
REQUEST_COOKIES: Final[Mapping[str, str]] = {
4141
".AspNet.SharedCookie": settings["SU_PLATFORM_ACCESS_COOKIE"]
4242
}
4343

44-
SU_PLATFORM_PROFILE_URL: "Final[str]" = "https://guildofstudents.com/profile"
45-
SU_PLATFORM_ORGANISATION_URL: "Final[str]" = (
46-
"https://www.guildofstudents.com/organisation/admin"
47-
)
44+
SU_PLATFORM_PROFILE_URL: Final[str] = "https://guildofstudents.com/profile"
45+
SU_PLATFORM_ORGANISATION_URL: Final[str] = "https://www.guildofstudents.com/organisation/admin"
4846

4947

5048
class SUPlatformAccessCookieStatus(Enum):
@@ -112,7 +110,7 @@ async def get_su_platform_access_cookie_status(self) -> SUPlatformAccessCookieSt
112110
)
113111
return SUPlatformAccessCookieStatus.INVALID
114112

115-
async def get_su_platform_organisations(self) -> "Iterable[str]":
113+
async def get_su_platform_organisations(self) -> Iterable[str]:
116114
"""Retrieve the MSL organisations the current SU platform cookie has access to."""
117115
response_object: bs4.BeautifulSoup = bs4.BeautifulSoup(
118116
await self._fetch_url_content_with_session(SU_PLATFORM_PROFILE_URL), "html.parser"
@@ -189,7 +187,7 @@ class CheckSUPlatformAuthorisationCommandCog(CheckSUPlatformAuthorisationBaseCog
189187
)
190188
@CommandChecks.check_interaction_user_has_committee_role
191189
@CommandChecks.check_interaction_user_in_main_guild
192-
async def check_su_platform_authorisation(self, ctx: "TeXBotApplicationContext") -> None:
190+
async def check_su_platform_authorisation(self, ctx: TeXBotApplicationContext) -> None:
193191
"""
194192
Definition of the "check_su_platform_authorisation" command.
195193
@@ -228,7 +226,7 @@ class CheckSUPlatformAuthorisationTaskCog(CheckSUPlatformAuthorisationBaseCog):
228226
"""Cog class defining a repeated task for checking SU platform access cookie."""
229227

230228
@override
231-
def __init__(self, bot: "TeXBot") -> None:
229+
def __init__(self, bot: TeXBot) -> None:
232230
"""Start all task managers when this cog is initialised."""
233231
if settings["AUTO_SU_PLATFORM_ACCESS_COOKIE_CHECKING"]:
234232
_ = self.su_platform_access_cookie_check_task.start()

cogs/command_error.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
from utils import TeXBotApplicationContext
2020

21-
__all__: "Sequence[str]" = ("CommandErrorCog",)
21+
__all__: Sequence[str] = ("CommandErrorCog",)
2222

2323

24-
logger: "Final[Logger]" = logging.getLogger("TeX-Bot")
24+
logger: Final[Logger] = logging.getLogger("TeX-Bot")
2525

2626

2727
class CommandErrorCog(TeXBotBaseCog):
2828
"""Cog class that defines additional code to execute upon a command error."""
2929

3030
@TeXBotBaseCog.listener()
3131
async def on_application_command_error(
32-
self, ctx: "TeXBotApplicationContext", error: discord.ApplicationCommandError
32+
self, ctx: TeXBotApplicationContext, error: discord.ApplicationCommandError
3333
) -> None:
3434
"""Log any major command errors in the logging channel & stderr."""
3535
error_code: str | None = None

0 commit comments

Comments
 (0)