Skip to content

Commit

Permalink
Update pre-commit hooks versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Jan 24, 2024
1 parent 690d2bb commit 46476e5
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 43 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:

repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.27.1
rev: v1.33.0
hooks:
- id: yamllint
- repo: https://github.com/psf/black
Expand All @@ -13,29 +13,29 @@ repos:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.260'
rev: 'v0.1.14'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py310-plus]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.6
hooks:
- id: codespell
args:
- --ignore-words-list=nd,som
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://github.com/hadolint/hadolint
rev: v2.10.0
rev: v2.12.1-beta
hooks:
- id: hadolint
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ into an account.
```

At this point you should be ready to develop! If you have any questions, don't
hesistate to reach out to me on the Pi-Bot Discord server listed above.
hesitate to reach out to me on the Pi-Bot Discord server listed above.

## Docker

Expand Down
4 changes: 2 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import re
import traceback
import uuid
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, ClassVar

import aiohttp
import discord
Expand Down Expand Up @@ -134,7 +134,7 @@ class PiBot(commands.Bot):

session: aiohttp.ClientSession | None
mongo_database: MongoDatabase
settings = {
settings: ClassVar[dict[str, str | int | None]] = {
"_id": None,
"custom_bot_status_type": None,
"custom_bot_status_text": None,
Expand Down
4 changes: 2 additions & 2 deletions src/discord/devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def getroleid(
"""
role = discord.utils.get(interaction.guild.roles, name=name)
if role is not None:
await interaction.response.send_message(f"{str(role)}: `{role.mention}`")
await interaction.response.send_message(f"{role!s}: `{role.mention}`")
else:
await interaction.response.send_message(
f"No role named `{name}` was found.",
Expand All @@ -98,7 +98,7 @@ async def getuserid(
if not member:
member = interaction.user

await interaction.response.send_message(f"{str(member)}: `{member.id}`")
await interaction.response.send_message(f"{member!s}: `{member.id}`")

@app_commands.command(description="Says hello!")
@app_commands.guilds(*SLASH_COMMAND_GUILDS)
Expand Down
15 changes: 6 additions & 9 deletions src/discord/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def callback(self, interaction: discord.Interaction) -> None:
timeout=120,
)

# After 120 seconds or the user repsonds, delete the prompt
# After 120 seconds or the user responds, delete the prompt
await info_message.delete()

# If the user didn't response, the embed field failed
Expand Down Expand Up @@ -496,11 +496,8 @@ async def callback(self, interaction: discord.Interaction) -> None:

class EmbedView(discord.ui.View):
# This will be updated when the user updates an embed property
embed_update: dict[
str,
Any,
] = {} # Keeps track of what was updated by a button press
embed_dict: dict[str, Any] = {}
embed_update: dict[str, Any] # Keeps track of what was updated by a button press
embed_dict: dict[str, Any]
user: discord.Member
channel: discord.TextChannel
stopped_status: str | None
Expand Down Expand Up @@ -816,7 +813,7 @@ async def prepembed(
self,
interaction: discord.Interaction,
channel: discord.TextChannel,
message_id: str = None,
message_id: str | None = None,
):
"""
Allows staff to send a new embed or edit an existing embed.
Expand Down Expand Up @@ -897,12 +894,12 @@ async def prepembed(
# Switch to field manager mode
embed_field_manager = True
embed_field_index = view.embed_update[
list(view.embed_update.items())[0][0]
next(iter(view.embed_update.items()))[0]
]["index"]

if "remove_field" in view.embed_update:
embed_field_index = view.embed_update[
list(view.embed_update.items())[0][0]
next(iter(view.embed_update.items()))[0]
]["index"]
embed_dict["fields"].pop(embed_field_index)

Expand Down
2 changes: 1 addition & 1 deletion src/discord/invitationals.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(
label=tourney.official_name
if tourney.status != "archived"
else f"{tourney.official_name} (archived)",
description=f"Occurs on {str(tourney.tourney_date.date())}.",
description=f"Occurs on {tourney.tourney_date.date()!s}.",
emoji=tourney.emoji,
),
)
Expand Down
12 changes: 6 additions & 6 deletions src/discord/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def on_message(self, message: discord.Message):
ping_count += 1
except Exception as e:
logger.error(
f"Could not evaluate message content with ping {ping} of user {user['user_id']}: {str(e)}",
f"Could not evaluate message content with ping {ping} of user {user['user_id']}: {e!s}",
)

if ping_count:
Expand All @@ -120,11 +120,11 @@ def format_text(
with respect to. This is used to get relevant ping info about the
specific user.
"""
user_ping_obj = [
user_ping_obj = next(
user_obj
for user_obj in src.discord.globals.PING_INFO
if user_obj["user_id"] == user.id
][0]
)
assert isinstance(user_ping_obj, dict)

pings = [rf"\b({ping})\b" for ping in user_ping_obj["word_pings"]]
Expand Down Expand Up @@ -273,7 +273,7 @@ async def pingadd(self, interaction: discord.Interaction, word: str):
"""
member = interaction.user
if any(
[True for u in src.discord.globals.PING_INFO if u["user_id"] == member.id],
(True for u in src.discord.globals.PING_INFO if u["user_id"] == member.id),
):
# User already has an object in the PING_INFO dictionary
user = next(
Expand All @@ -293,11 +293,11 @@ async def pingadd(self, interaction: discord.Interaction, word: str):
)
else:
logger.debug(f"adding word: {re.escape(word)}")
relevant_doc = [
relevant_doc = next(
doc
for doc in src.discord.globals.PING_INFO
if doc["user_id"] == member.id
][0]
)
relevant_doc["word_pings"].append(word)
await self.bot.mongo_database.update(
"data",
Expand Down
10 changes: 5 additions & 5 deletions src/discord/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def callback(self, interaction: discord.Interaction):

class ChangeInappropriateUsername(discord.ui.Button):
"""
A button that changes the username of a user. This caues the report message
A button that changes the username of a user. This causes the report message
to be deleted, an informational message to be posted in #closed-reports,
and the report database to be updated.
"""
Expand Down Expand Up @@ -554,7 +554,7 @@ async def create_cron_unban_auto_notice(
self,
user: discord.User,
is_present: bool,
already_unbanned: bool = None,
already_unbanned: bool | None = None,
) -> None:
"""
Creates a notice (as a closed report) that a user was automatically
Expand All @@ -581,11 +581,11 @@ async def create_cron_unban_auto_notice(
)
elif not is_present and not already_unbanned:
await closed_reports_channel.send(
f"**User was automatically unbanned by CRON.** A previous timed ban on {str(user)} expired, and therefore, CRON has unbanned the user. The user is free to join the server at any time.",
f"**User was automatically unbanned by CRON.** A previous timed ban on {user!s} expired, and therefore, CRON has unbanned the user. The user is free to join the server at any time.",
)
elif not is_present and already_unbanned:
await closed_reports_channel.send(
f"**Attempt to automatically unban user by CRON.** A previous timed ban on {str(user)} expired, and therefore, CRON attempted to unban the user. However, the user was already unbanned. The user remains free to join the server at any time.",
f"**Attempt to automatically unban user by CRON.** A previous timed ban on {user!s} expired, and therefore, CRON attempted to unban the user. However, the user was already unbanned. The user remains free to join the server at any time.",
)

async def create_cron_unmute_auto_notice(
Expand Down Expand Up @@ -618,7 +618,7 @@ async def create_cron_unmute_auto_notice(
)
elif not is_present:
await closed_reports_channel.send(
f"**Attempt to automatically unmute user by CRON.** A previous timed mute on {str(user)} expired, "
f"**Attempt to automatically unmute user by CRON.** A previous timed mute on {user!s} expired, "
f"and therefore, CRON attempted to unmute the user. "
f"However, because the user is no longer present in the server, no unmute could occur.",
)
Expand Down
2 changes: 1 addition & 1 deletion src/discord/spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class SpamManager(commands.Cog):

recent_messages = []
recent_messages: list[discord.Message]

# Limits
recent_messages_limit = 20 # The number of recent messages that are stored
Expand Down
10 changes: 5 additions & 5 deletions src/discord/staff/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def event_add(
self,
interaction: discord.Interaction,
event_name: str,
event_aliases: str = None,
event_aliases: str | None = None,
):
# Check for staff permissions
commandchecks.is_staff_from_ctx(interaction)
Expand Down Expand Up @@ -78,7 +78,7 @@ async def event_add(
await server.create_role(
name=event_name,
color=discord.Color(0x82A3D3),
reason=f"Created by {str(interaction.user)} using /eventadd with Pi-Bot.",
reason=f"Created by {interaction.user!s} using /eventadd with Pi-Bot.",
)

# Notify user of process completion
Expand Down Expand Up @@ -136,9 +136,9 @@ async def event_remove(
)

# Complete operation of removing event
event = [e for e in src.discord.globals.EVENT_INFO if e["name"] == event_name][
0
]
event = next(
e for e in src.discord.globals.EVENT_INFO if e["name"] == event_name
)
src.discord.globals.EVENT_INFO.remove(event)
await self.bot.mongo_database.delete("data", "events", event["_id"])

Expand Down
2 changes: 1 addition & 1 deletion src/discord/staff/invitationals.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def invitational_add(
)
created_emoji = True
emoji_creation_message = await interaction.channel.send(
f"Created {emoji} (`{str(emoji)}`) emoji in guild `{guild_id}`. (Guild {i + 1}/{len(EMOJI_GUILDS)})",
f"Created {emoji} (`{emoji!s}`) emoji in guild `{guild_id}`. (Guild {i + 1}/{len(EMOJI_GUILDS)})",
)
await emoji_creation_message.delete(delay=10)
break
Expand Down
4 changes: 2 additions & 2 deletions src/discord/staff/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def tag_edit(
)

# Get relevant tag
tag = [t for t in src.discord.globals.TAGS if t["name"] == tag_name][0]
tag = next(t for t in src.discord.globals.TAGS if t["name"] == tag_name)

# Send info message about updating tag
await interaction.edit_original_response(
Expand Down Expand Up @@ -209,7 +209,7 @@ async def tag_remove(
)

# Get tag
tag = [t for t in src.discord.globals.TAGS if t["name"] == tag_name][0]
tag = next(t for t in src.discord.globals.TAGS if t["name"] == tag_name)
# and remove it!
src.discord.globals.TAGS.remove(tag)
# and delete it from the DB!
Expand Down
4 changes: 2 additions & 2 deletions src/discord/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ async def unselfmute_button(
role = discord.utils.get(interaction.guild.roles, name=ROLE_SELFMUTE)
await interaction.user.remove_roles(role)
try:
item = [
item = next(
x
for x in await self.bot.mongo_database.get_cron()
if (x["type"] == "UNSELFMUTE" and x["user"] == interaction.user.id)
][0]
)
await self.bot.mongo_database.remove_doc("data", "cron", item["_id"])
except Exception: # not in the database - maybe was removed!
pass
Expand Down

0 comments on commit 46476e5

Please sign in to comment.