Skip to content

Commit

Permalink
Merge pull request #1389 from python-discord/dependabot/pip/ruff-0.1.3
Browse files Browse the repository at this point in the history
Bump ruff from 0.0.292 to 0.1.3
  • Loading branch information
ChrisLovering authored Nov 8, 2023
2 parents 2377c78 + 428c8de commit 9a1b5f4
Show file tree
Hide file tree
Showing 19 changed files with 403 additions and 428 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

# Run `ruff` using github formatting to enable automatic inline annotations.
- name: Run ruff
run: "ruff check --format=github ."
run: "ruff check --output-format=github ."

# Prepare the Pull Request Payload artifact. If this fails, we
# we fail silently using the `continue-on-error` option. It's
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ repos:

- repo: local
hooks:
- id: isort
name: isort
description: This hook runs isort within our project's environment.
entry: poetry run isort
language: system
types: [python]
require_serial: true

- id: ruff
name: ruff
description: Run ruff linting
Expand Down
5 changes: 2 additions & 3 deletions bot/exts/fun/battleship.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
import random
import re
Expand Down Expand Up @@ -244,7 +243,7 @@ async def take_turn(self) -> Square | None:
while True:
try:
await self.bot.wait_for("message", check=self.predicate, timeout=60.0)
except asyncio.TimeoutError:
except TimeoutError:
await self.turn.user.send("You took too long. Game over!")
await self.next.user.send(f"{self.turn.user} took too long. Game over!")
await self.public_channel.send(
Expand Down Expand Up @@ -400,7 +399,7 @@ async def battleship(self, ctx: commands.Context) -> None:
check=partial(self.predicate, ctx, announcement),
timeout=60.0
)
except asyncio.TimeoutError:
except TimeoutError:
self.waiting.remove(ctx.author)
await announcement.delete()
await ctx.send(f"{ctx.author.mention} Seems like there's no one here to play...")
Expand Down
5 changes: 2 additions & 3 deletions bot/exts/fun/connect_four.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import random
from functools import partial

Expand Down Expand Up @@ -131,7 +130,7 @@ async def player_turn(self) -> Coordinate:
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", check=self.predicate, timeout=30.0)
except asyncio.TimeoutError:
except TimeoutError:
await self.channel.send(f"{self.player_active.mention}, you took too long. Game over!")
return None
else:
Expand Down Expand Up @@ -406,7 +405,7 @@ async def connect_four(
check=partial(self.get_player, ctx, announcement),
timeout=60.0
)
except asyncio.TimeoutError:
except TimeoutError:
self.waiting.remove(ctx.author)
await announcement.delete()
await ctx.send(
Expand Down
8 changes: 4 additions & 4 deletions bot/exts/fun/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ async def create_page(self, data: dict[str, Any]) -> tuple[str, str]:
"url": data["url"],
"description": f"{data['summary']}\n\n" if "summary" in data else "\n",
"release_date": release_date,
"rating": round(data["total_rating"] if "total_rating" in data else 0, 2),
"rating_count": data["total_rating_count"] if "total_rating_count" in data else "?",
"rating": round(data.get("total_rating", 0), 2),
"rating_count": data.get("total_rating_count", "?"),
"platforms": ", ".join(platform["name"] for platform in data["platforms"]) if "platforms" in data else "?",
"status": GameStatus(data["status"]).name if "status" in data else "?",
"age_ratings": rating,
"made_by": ", ".join(companies),
"storyline": data["storyline"] if "storyline" in data else ""
"storyline": data.get("storyline", "")
}
page = GAME_PAGE.format(**formatting)

Expand All @@ -448,7 +448,7 @@ async def search_games(self, search_term: str) -> list[str]:
formatting = {
"name": game["name"],
"url": game["url"],
"rating": round(game["total_rating"] if "total_rating" in game else 0, 2),
"rating": round(game.get("total_rating", 0), 2),
"rating_count": game["total_rating_count"] if "total_rating" in game else "?"
}
line = GAME_SEARCH_LINE.format(**formatting)
Expand Down
1 change: 0 additions & 1 deletion bot/exts/fun/hangman.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from asyncio import TimeoutError
from pathlib import Path
from random import choice

Expand Down
1 change: 0 additions & 1 deletion bot/exts/fun/madlibs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from asyncio import TimeoutError
from pathlib import Path
from random import choice
from typing import TypedDict
Expand Down
6 changes: 3 additions & 3 deletions bot/exts/fun/snakes/_snakes_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async def _fetch(self, url: str, params: dict | None = None) -> dict:
params = {}

async with self.bot.http_session.get(url, params=params, timeout=ClientTimeout(total=10)) as response:
return await response.json()
return await response.json()

def _get_random_long_message(self, messages: list[str], retries: int = 10) -> str:
"""
Expand Down Expand Up @@ -422,7 +422,7 @@ def predicate(reaction: Reaction, user: Member) -> bool:
# Validate the answer
try:
reaction, user = await ctx.bot.wait_for("reaction_add", timeout=45.0, check=predicate)
except asyncio.TimeoutError:
except TimeoutError:
await ctx.send(f"You took too long. The correct answer was **{options[answer]}**.")
await message.clear_reactions()
return
Expand Down Expand Up @@ -516,7 +516,7 @@ def predicate(reaction_: Reaction, user_: Member) -> bool:
try:
reaction, user = await ctx.bot.wait_for(
"reaction_add", timeout=300, check=predicate)
except asyncio.TimeoutError:
except TimeoutError:
log.debug("Antidote timed out waiting for a reaction")
break # We're done, no reactions for the last 5 minutes

Expand Down
5 changes: 2 additions & 3 deletions bot/exts/fun/snakes/_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import io
import json
import logging
Expand Down Expand Up @@ -453,7 +452,7 @@ def startup_event_check(reaction_: Reaction, user_: User | Member) -> bool:

await startup.remove_reaction(reaction.emoji, user)

except asyncio.TimeoutError:
except TimeoutError:
log.debug("Snakes and Ladders timed out waiting for a reaction")
await self.cancel_game()
return # We're done, no reactions for the last 5 minutes
Expand Down Expand Up @@ -630,7 +629,7 @@ def game_event_check(reaction_: Reaction, user_: User | Member) -> bool:
if self._check_all_rolled():
break

except asyncio.TimeoutError:
except TimeoutError:
log.debug("Snakes and Ladders timed out waiting for a reaction")
await self.cancel_game()
return # We're done, no reactions for the last 5 minutes
Expand Down
5 changes: 2 additions & 3 deletions bot/exts/fun/tic_tac_toe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import random
from collections.abc import Callable

Expand Down Expand Up @@ -59,7 +58,7 @@ def check_for_move(r: discord.Reaction, u: discord.User) -> bool:

try:
react, _ = await self.ctx.bot.wait_for("reaction_add", timeout=30.0, check=check_for_move)
except asyncio.TimeoutError:
except TimeoutError:
return True, None
else:
return False, list(Emojis.number_emojis.keys())[list(Emojis.number_emojis.values()).index(react.emoji)]
Expand Down Expand Up @@ -162,7 +161,7 @@ def confirm_check(reaction: discord.Reaction, user: discord.User) -> bool:
timeout=60.0,
check=confirm_check
)
except asyncio.TimeoutError:
except TimeoutError:
self.over = True
self.canceled = True
await confirm_message.delete()
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/fun/trivia_quiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def contains_correct_answer(m: discord.Message) -> bool:

try:
msg = await self.bot.wait_for("message", check=check_func(quiz_entry.var_tol), timeout=10)
except asyncio.TimeoutError:
except TimeoutError:
# In case of TimeoutError and the game has been stopped, then do nothing.
if not self.game_status[ctx.channel.id]:
break
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/holidays/pride/pride_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def pridefact(self, ctx: commands.Context, option: int | str | None = None
await ctx.send(f"Could not parse option {option}")

@staticmethod
def get_fact_embed(day_num: int | None=None) -> discord.Embed:
def get_fact_embed(day_num: int | None = None) -> discord.Embed:
"""
Makes a embed for the fact on the given day_num to be sent.
Expand Down
3 changes: 1 addition & 2 deletions bot/exts/utilities/conversationstarters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
from contextlib import suppress
from functools import partial
from pathlib import Path
Expand Down Expand Up @@ -94,7 +93,7 @@ async def _listen_for_refresh(
check=partial(self._predicate, command_invoker, message),
timeout=60.0
)
except asyncio.TimeoutError:
except TimeoutError:
with suppress(discord.NotFound):
await message.clear_reaction("🔄")
break
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/utilities/githubinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ async def github_user_info(self, ctx: commands.Context, username: str) -> None:
embed.add_field(name="Gists", value=f"[{gists}](https://gist.github.com/{quote(username, safe='')})")

embed.add_field(
name=f"Organization{'s' if len(orgs)!=1 else ''}",
name=f"Organization{'s' if len(orgs) != 1 else ''}",
value=orgs_to_add if orgs else "No organizations."
)
embed.add_field(name="Website", value=blog)
Expand Down
2 changes: 1 addition & 1 deletion bot/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def check(message: discord.Message) -> bool:

try:
message = await ctx.bot.wait_for("message", check=check, timeout=timeout)
except asyncio.TimeoutError:
except TimeoutError:
raise BadArgument("Timed out.")

try:
Expand Down
9 changes: 8 additions & 1 deletion bot/utils/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
from collections.abc import Callable, Container, Iterable

from discord.ext.commands import (
BucketType, CheckFailure, Cog, Command, CommandOnCooldown, Context, Cooldown, CooldownMapping
BucketType,
CheckFailure,
Cog,
Command,
CommandOnCooldown,
Context,
Cooldown,
CooldownMapping,
)

from bot import constants
Expand Down
5 changes: 2 additions & 3 deletions bot/utils/pagination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
from collections.abc import Iterable

Expand Down Expand Up @@ -197,7 +196,7 @@ def event_check(reaction_: Reaction, user_: Member) -> bool:
try:
reaction, user = await ctx.bot.wait_for("reaction_add", timeout=timeout, check=event_check)
log.trace(f"Got reaction: {reaction}")
except asyncio.TimeoutError:
except TimeoutError:
log.debug("Timed out waiting for a reaction")
break # We're done, no reactions for the last 5 minutes

Expand Down Expand Up @@ -372,7 +371,7 @@ def check_event(reaction_: Reaction, member: Member) -> bool:
# Start waiting for reactions
try:
reaction, user = await ctx.bot.wait_for("reaction_add", timeout=timeout, check=check_event)
except asyncio.TimeoutError:
except TimeoutError:
log.debug("Timed out waiting for a reaction")
break # We're done, no reactions for the last 5 minutes

Expand Down
Loading

0 comments on commit 9a1b5f4

Please sign in to comment.