Skip to content

Commit bf65898

Browse files
Refactor for new checks
1 parent a0d4ee7 commit bf65898

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

cogs/everest.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,21 @@ class EverestCommandCog(TeXBotBaseCog):
2727
"""Cog class that defines the "/everest" command and its call-back method."""
2828

2929
@staticmethod
30-
async def autocomplete_get_course_types(ctx: "TeXBotAutocompleteContext",) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]": # noqa: E501, ARG004
30+
async def autocomplete_get_course_types(
31+
ctx: "TeXBotAutocompleteContext", # noqa: ARG004
32+
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[str]":
3133
"""Autocomplete for the course type option."""
3234
return POSSIBLE_COURSE_TYPES
3335

3436
@staticmethod
35-
async def autocomplete_get_course_years(ctx: "TeXBotAutocompleteContext",) -> "AbstractSet[discord.OptionChoice] | AbstractSet[int]": # noqa: E501, ARG004
37+
async def autocomplete_get_course_years(
38+
ctx: "TeXBotAutocompleteContext", # noqa: ARG004
39+
) -> "AbstractSet[discord.OptionChoice] | AbstractSet[int]":
3640
"""Autocomplete for the course year option."""
3741
return POSSIBLE_YEARS
3842

3943
@discord.slash_command( # type: ignore[no-untyped-call, misc]
40-
name="everest",
41-
description="How many steps of everest is your assignment worth?"
44+
name="everest", description="How many steps of everest is your assignment worth?"
4245
)
4346
@discord.option( # type: ignore[no-untyped-call, misc]
4447
name="course-type",
@@ -62,7 +65,13 @@ async def autocomplete_get_course_years(ctx: "TeXBotAutocompleteContext",) -> "A
6265
input_type=float,
6366
required=True,
6467
)
65-
async def everest(self, ctx: "TeXBotApplicationContext", course_type: str, current_course_year: int, module_percentage: float) -> None:
68+
async def everest( # type: ignore[misc]
69+
self,
70+
ctx: "TeXBotApplicationContext",
71+
course_type: str,
72+
current_course_year: int,
73+
module_percentage: float,
74+
) -> None:
6675
"""Calculate how many steps of Mount Everest an assignment is worth."""
6776
if course_type not in POSSIBLE_COURSE_TYPES:
6877
await ctx.respond(
@@ -83,8 +92,8 @@ async def everest(self, ctx: "TeXBotApplicationContext", course_type: str, curre
8392
return
8493

8594
if current_course_year not in POSSIBLE_YEARS:
86-
await ctx.respond(content=INVALID_COURSE_YEAR_MESSAGE)
87-
return
95+
await ctx.respond(content=INVALID_COURSE_YEAR_MESSAGE)
96+
return
8897

8998
INVALID_MODULE_WEIGHT_MESSAGE: Final[str] = (
9099
f"Module weight: {module_percentage} is not valid."
@@ -100,7 +109,6 @@ async def everest(self, ctx: "TeXBotApplicationContext", course_type: str, curre
100109
await ctx.respond(content=INVALID_MODULE_WEIGHT_MESSAGE)
101110
return
102111

103-
104112
if current_course_year == 4 and course_type == "B.Sc.":
105113
await ctx.respond(
106114
content=(
@@ -117,7 +125,9 @@ async def everest(self, ctx: "TeXBotApplicationContext", course_type: str, curre
117125
if course_type == "msci":
118126
year_value = MSCI_WEIGHTINGS[current_course_year - 1]
119127

120-
steps = (module_weight / 100) * 1 / 6 * year_value * 44250 # NOTE: Assumes all modules are 20 credits
128+
steps = (
129+
(module_weight / 100) * 1 / 6 * year_value * 44250
130+
) # NOTE: Assumes all modules are 20 credits
121131

122132
await ctx.respond(
123133
content=(

0 commit comments

Comments
 (0)