diff options
Diffstat (limited to 'bot/exts/events')
| -rw-r--r-- | bot/exts/events/hacktoberfest/hacktoberstats.py | 4 | ||||
| -rw-r--r-- | bot/exts/events/trivianight/_game.py | 4 | ||||
| -rw-r--r-- | bot/exts/events/trivianight/_scoreboard.py | 6 | ||||
| -rw-r--r-- | bot/exts/events/trivianight/trivianight.py | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/bot/exts/events/hacktoberfest/hacktoberstats.py b/bot/exts/events/hacktoberfest/hacktoberstats.py index c7fd3601..04dc4aae 100644 --- a/bot/exts/events/hacktoberfest/hacktoberstats.py +++ b/bot/exts/events/hacktoberfest/hacktoberstats.py @@ -43,7 +43,7 @@ class HacktoberStats(commands.Cog): @in_month(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER) @commands.group(name="hacktoberstats", aliases=("hackstats",), invoke_without_command=True) - async def hacktoberstats_group(self, ctx: commands.Context, github_username: str = None) -> None: + async def hacktoberstats_group(self, ctx: commands.Context, github_username: str | None = None) -> None: """ Display an embed for a user's Hacktoberfest contributions. @@ -70,7 +70,7 @@ class HacktoberStats(commands.Cog): @in_month(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER) @hacktoberstats_group.command(name="link") - async def link_user(self, ctx: commands.Context, github_username: str = None) -> None: + async def link_user(self, ctx: commands.Context, github_username: str | None = None) -> None: """ Link the invoking user's Github github_username to their Discord ID. diff --git a/bot/exts/events/trivianight/_game.py b/bot/exts/events/trivianight/_game.py index 15126f60..0568ce81 100644 --- a/bot/exts/events/trivianight/_game.py +++ b/bot/exts/events/trivianight/_game.py @@ -134,7 +134,7 @@ class TriviaNightGame: def __iter__(self) -> Iterable[Question]: return iter(self._questions) - def next_question(self, number: str = None) -> Question: + def next_question(self, number: str | None = None) -> Question: """ Consume one random question from the trivia night game. @@ -145,7 +145,7 @@ class TriviaNightGame: if number is not None: try: - question = [q for q in self._all_questions if q.number == int(number)][0] + question = next(q for q in self._all_questions if q.number == int(number)) except IndexError: raise ValueError(f"Question number {number} does not exist.") elif len(self._questions) == 0: diff --git a/bot/exts/events/trivianight/_scoreboard.py b/bot/exts/events/trivianight/_scoreboard.py index bd61be3d..c2b39d67 100644 --- a/bot/exts/events/trivianight/_scoreboard.py +++ b/bot/exts/events/trivianight/_scoreboard.py @@ -155,18 +155,18 @@ class Scoreboard: self._points = {} self._speed = {} - def assign_points(self, user_id: int, *, points: int = None, speed: float = None) -> None: + def assign_points(self, user_id: int, *, points: int | None = None, speed: float | None = None) -> None: """ Assign points or deduct points to/from a certain user. This method should be called once the question has finished and all answers have been registered. """ - if points is not None and user_id not in self._points.keys(): + if points is not None and user_id not in self._points: self._points[user_id] = points elif points is not None: self._points[user_id] += points - if speed is not None and user_id not in self._speed.keys(): + if speed is not None and user_id not in self._speed: self._speed[user_id] = [1, speed] elif speed is not None: self._speed[user_id] = [ diff --git a/bot/exts/events/trivianight/trivianight.py b/bot/exts/events/trivianight/trivianight.py index e0db45d8..e47d1d83 100644 --- a/bot/exts/events/trivianight/trivianight.py +++ b/bot/exts/events/trivianight/trivianight.py @@ -107,7 +107,7 @@ class TriviaNightCog(commands.Cog): @trivianight.command(aliases=("next",)) @commands.has_any_role(*TRIVIA_NIGHT_ROLES) - async def question(self, ctx: commands.Context, question_number: str = None) -> None: + async def question(self, ctx: commands.Context, question_number: str | None = None) -> None: """ Gets a random question from the unanswered question list and lets the user(s) choose the answer. |