Skip to content

Commit bfceef6

Browse files
committed
fmt all files to line-length of 88
1 parent 42e344d commit bfceef6

24 files changed

+123
-313
lines changed

bot/cogs/__init__.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,5 @@ def __str__(self) -> str:
1212
return f"{self.major}.{self.minor}.{self.micro}-{self.releaselevel}"
1313

1414

15-
EXTENSIONS = [
16-
module.name for module in iter_modules(__path__, f"{__package__}.")
17-
]
18-
VERSION: VersionInfo = VersionInfo(
19-
major=0, minor=3, micro=1, releaselevel="final"
20-
)
15+
EXTENSIONS = [module.name for module in iter_modules(__path__, f"{__package__}.")]
16+
VERSION: VersionInfo = VersionInfo(major=0, minor=3, micro=1, releaselevel="final")

bot/cogs/admin.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ def tick(self, opt: Optional[bool], label: Optional[str] = None) -> str:
7474

7575
def format_results(self, statuses: list) -> str:
7676
desc = "\U00002705 - Successful reload | \U0000274c - Failed reload | \U000023e9 - Skipped\n\n"
77-
status = "\n".join(
78-
f"- {status}: `{module}`" for status, module in statuses
79-
)
77+
status = "\n".join(f"- {status}: `{module}`" for status, module in statuses)
8078
desc += status
8179
return desc
8280

@@ -161,10 +159,11 @@ async def reload(self, ctx: RoboContext) -> None:
161159
modules = self.find_modules_from_git(stdout)
162160

163161
mods_text = "\n".join(
164-
f"{index}. `{module}`"
165-
for index, (_, module) in enumerate(modules, start=1)
162+
f"{index}. `{module}`" for index, (_, module) in enumerate(modules, start=1)
163+
)
164+
prompt_text = (
165+
f"This will update the following modules, are you sure?\n{mods_text}"
166166
)
167-
prompt_text = f"This will update the following modules, are you sure?\n{mods_text}"
168167

169168
confirm = await ctx.prompt(prompt_text)
170169
if not confirm:

bot/cogs/config.py

+31-70
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ async def _load(self, connection: Union[asyncpg.Connection, asyncpg.Pool]):
8282
"""
8383
rows = await connection.fetch(query)
8484
return {
85-
row["entity_id"]: BlocklistEntity(bot=self.bot, **dict(row))
86-
for row in rows
85+
row["entity_id"]: BlocklistEntity(bot=self.bot, **dict(row)) for row in rows
8786
}
8887

8988
async def load(self, connection: Optional[asyncpg.Connection] = None):
@@ -247,9 +246,7 @@ def __init__(self, entry: ConfigHelpEntry, **kwargs):
247246
self.title = entry.key
248247
self.description = entry.description
249248
self.add_field(name="Default", value=entry.default, inline=False)
250-
self.add_field(
251-
name="Example(s)", value="\n".join(entry.examples), inline=False
252-
)
249+
self.add_field(name="Example(s)", value="\n".join(entry.examples), inline=False)
253250
self.add_field(
254251
name="Notes",
255252
value="\n".join(f"- {note}" for note in entry.notes) or None,
@@ -278,9 +275,7 @@ def __init__(self, entries: dict[str, Any], active: Optional[bool] = None):
278275
super().__init__(self.config_iterator(entries), per_page=20)
279276
self.active = active
280277

281-
async def config_iterator(
282-
self, entries: dict[str, Any]
283-
) -> AsyncIterator[str]:
278+
async def config_iterator(self, entries: dict[str, Any]) -> AsyncIterator[str]:
284279
for key, entry in entries.items():
285280
result = f"**{key}:** {entry}"
286281
# Wtf is wrong with me - Noelle
@@ -293,9 +288,7 @@ async def config_iterator(
293288

294289
async def format_page(self, menu: ConfigPages, entries: list[str]):
295290
pages = []
296-
for _, entry in enumerate(
297-
entries, start=menu.current_page * self.per_page
298-
):
291+
for _, entry in enumerate(entries, start=menu.current_page * self.per_page):
299292
pages.append(f"{entry}")
300293

301294
menu.embed.description = "\n".join(pages)
@@ -311,9 +304,7 @@ def __init__(
311304
active: Optional[bool] = None,
312305
):
313306
super().__init__(ConfigPageSource(entries, active), ctx=ctx)
314-
self.embed = discord.Embed(
315-
colour=discord.Colour.from_rgb(200, 168, 255)
316-
)
307+
self.embed = discord.Embed(colour=discord.Colour.from_rgb(200, 168, 255))
317308

318309

319310
class ConfigOptionFlags(commands.FlagConverter):
@@ -354,9 +345,7 @@ async def convert(self, ctx: GuildContext, argument: str) -> str:
354345
raise RuntimeError("Unable to get Config cog")
355346

356347
if lowered not in cog.config_keys:
357-
raise commands.BadArgument(
358-
self.disambiguate(lowered, cog.config_keys)
359-
)
348+
raise commands.BadArgument(self.disambiguate(lowered, cog.config_keys))
360349

361350
return lowered
362351

@@ -380,9 +369,7 @@ class PrefixConverter(commands.Converter):
380369
async def convert(self, ctx: GuildContext, argument: str):
381370
user_id = ctx.bot.user.id # type: ignore # Already logged in by this time
382371
if argument.startswith((f"<@{user_id}>", f"<@!{user_id}>", "r>")):
383-
raise commands.BadArgument(
384-
"That is a reserved prefix already in use."
385-
)
372+
raise commands.BadArgument("That is a reserved prefix already in use.")
386373
if len(argument) > 100:
387374
raise commands.BadArgument("That prefix is too long.")
388375
return argument
@@ -425,10 +412,10 @@ async def get_guild_config(self, guild_id: int) -> Optional[GuildConfig]:
425412
return config
426413

427414
@alru_cache()
428-
async def get_guild_settings(
429-
self, guild_id: int
430-
) -> Optional[GuildSettings]:
431-
query = "SELECT account_age, guild_age, settings FROM guild_config WHERE id = $1;"
415+
async def get_guild_settings(self, guild_id: int) -> Optional[GuildSettings]:
416+
query = (
417+
"SELECT account_age, guild_age, settings FROM guild_config WHERE id = $1;"
418+
)
432419
rows = await self.pool.fetchrow(query, guild_id)
433420
if rows is None:
434421
self.get_guild_settings.cache_invalidate(guild_id)
@@ -460,9 +447,7 @@ async def set_guild_settings(
460447
config_type: ConfigType,
461448
ctx: GuildContext,
462449
):
463-
current_guild_settings = await self.get_partial_guild_settings(
464-
ctx.guild.id
465-
)
450+
current_guild_settings = await self.get_partial_guild_settings(ctx.guild.id)
466451

467452
# If there are no guild configurations, then we have an issue here
468453
# we will denote this with an error
@@ -488,20 +473,12 @@ async def set_guild_settings(
488473
self.get_partial_guild_settings.cache_invalidate(ctx.guild.id)
489474

490475
command_type = "Toggled" if config_type == ConfigType.TOGGLE else "Set"
491-
await ctx.send(
492-
f"{command_type} `{key}` from `{original_value}` to `{value}`"
493-
)
476+
await ctx.send(f"{command_type} `{key}` from `{original_value}` to `{value}`")
494477

495478
### Blocklist utilities
496479

497-
async def can_be_blocked(
498-
self, ctx: GuildContext, entity: discord.Member
499-
) -> bool:
500-
if (
501-
entity.id == ctx.author.id
502-
or await self.bot.is_owner(entity)
503-
or entity.bot
504-
):
480+
async def can_be_blocked(self, ctx: GuildContext, entity: discord.Member) -> bool:
481+
if entity.id == ctx.author.id or await self.bot.is_owner(entity) or entity.bot:
505482
return False
506483

507484
# Hierarchy check
@@ -602,7 +579,9 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
602579
manage_threads=True,
603580
),
604581
}
605-
lgc_reason = f"{ctx.author} (ID: {ctx.author.id}) has created the Rodhaj logs channel"
582+
lgc_reason = (
583+
f"{ctx.author} (ID: {ctx.author.id}) has created the Rodhaj logs channel"
584+
)
606585

607586
# The rationale behind the restriction of posts is to make sure that
608587
# people don't create posts of their own, thus messing up the code for the bot
@@ -626,9 +605,7 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
626605
),
627606
discord.ForumTag(
628607
name="Serious",
629-
emoji=discord.PartialEmoji(
630-
name="\U0001f610"
631-
), # U+1F610 Neutral Face
608+
emoji=discord.PartialEmoji(name="\U0001f610"), # U+1F610 Neutral Face
632609
),
633610
discord.ForumTag(
634611
name="Private",
@@ -732,7 +709,9 @@ async def delete(self, ctx: GuildContext) -> None:
732709
confirm = await ctx.prompt(msg, timeout=300.0, delete_after=True)
733710
if confirm:
734711
if guild_config is None:
735-
msg = "Could not find the guild config. Perhaps Rodhaj is not set up yet?"
712+
msg = (
713+
"Could not find the guild config. Perhaps Rodhaj is not set up yet?"
714+
)
736715
await ctx.send(msg)
737716
return
738717

@@ -809,9 +788,7 @@ async def config_options(
809788
await ctx.send(msg)
810789
return
811790

812-
pages = ConfigPages(
813-
guild_settings.to_dict(), ctx=ctx, active=flags.active
814-
)
791+
pages = ConfigPages(guild_settings.to_dict(), ctx=ctx, active=flags.active)
815792
await pages.start()
816793

817794
@is_manager()
@@ -823,9 +800,7 @@ async def config_help(
823800
) -> None:
824801
"""Shows help information for different configuration options"""
825802
# Because we are using the converter, all options are guaranteed to be correct
826-
embed = ConfigEntryEmbed(
827-
ConfigHelpEntry(key=key, **self.options_help[key])
828-
)
803+
embed = ConfigEntryEmbed(ConfigHelpEntry(key=key, **self.options_help[key]))
829804
await ctx.send(embed=embed)
830805

831806
@is_manager()
@@ -908,9 +883,7 @@ async def config_set(
908883
)
909884
return
910885

911-
await self.set_guild_settings(
912-
key, value, config_type=ConfigType.SET, ctx=ctx
913-
)
886+
await self.set_guild_settings(key, value, config_type=ConfigType.SET, ctx=ctx)
914887

915888
@is_manager()
916889
@commands.guild_only()
@@ -1044,9 +1017,7 @@ async def prefix_edit(
10441017
get_prefix.cache_invalidate(self.bot, ctx.message)
10451018
await ctx.send(f"Prefix updated to from `{old}` to `{new}`")
10461019
else:
1047-
await ctx.send(
1048-
"The prefix is not in the list of prefixes for your server"
1049-
)
1020+
await ctx.send("The prefix is not in the list of prefixes for your server")
10501021

10511022
@is_manager()
10521023
@commands.guild_only()
@@ -1066,9 +1037,7 @@ async def prefix_delete(
10661037
if confirm:
10671038
await self.pool.execute(query, prefix, ctx.guild.id)
10681039
get_prefix.cache_invalidate(self.bot, ctx.message)
1069-
await ctx.send(
1070-
f"The prefix `{prefix}` has been successfully deleted"
1071-
)
1040+
await ctx.send(f"The prefix `{prefix}` has been successfully deleted")
10721041
elif confirm is None:
10731042
await ctx.send("Confirmation timed out. Cancelled deletion...")
10741043
else:
@@ -1081,9 +1050,7 @@ async def prefix_delete(
10811050
# 4. Is the author themselves trying to get blocklisted?
10821051
# This system must be addressed with care as it is extremely dangerous
10831052
# TODO: Add an history command to view past history of entity
1084-
@check_permissions(
1085-
manage_messages=True, manage_roles=True, moderate_members=True
1086-
)
1053+
@check_permissions(manage_messages=True, manage_roles=True, moderate_members=True)
10871054
@commands.guild_only()
10881055
@commands.hybrid_group(name="blocklist", fallback="info")
10891056
async def blocklist(self, ctx: GuildContext) -> None:
@@ -1092,9 +1059,7 @@ async def blocklist(self, ctx: GuildContext) -> None:
10921059
pages = BlocklistPages([entry for entry in blocklist.values()], ctx=ctx)
10931060
await pages.start()
10941061

1095-
@check_permissions(
1096-
manage_messages=True, manage_roles=True, moderate_members=True
1097-
)
1062+
@check_permissions(manage_messages=True, manage_roles=True, moderate_members=True)
10981063
@commands.guild_only()
10991064
@blocklist.command(name="add")
11001065
@app_commands.describe(
@@ -1155,15 +1120,11 @@ async def blocklist_add(
11551120
)
11561121
await ctx.send(f"{entity.mention} has been blocked")
11571122

1158-
@check_permissions(
1159-
manage_messages=True, manage_roles=True, moderate_members=True
1160-
)
1123+
@check_permissions(manage_messages=True, manage_roles=True, moderate_members=True)
11611124
@commands.guild_only()
11621125
@blocklist.command(name="remove")
11631126
@app_commands.describe(entity="The member to remove from the blocklist")
1164-
async def blocklist_remove(
1165-
self, ctx: GuildContext, entity: discord.Member
1166-
) -> None:
1127+
async def blocklist_remove(self, ctx: GuildContext, entity: discord.Member) -> None:
11671128
"""Removes an member from the blocklist"""
11681129
if not await self.can_be_blocked(ctx, entity):
11691130
await ctx.send("Failed to unblock entity")

bot/cogs/ext/prometheus.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ def __init__(self, bot: Rodhaj):
6767
["shard"],
6868
states=["connected", "disconnected"],
6969
)
70-
self.latency = Gauge(
71-
f"{METRIC_PREFIX}latency", "Latency to Discord", ["shard"]
72-
)
73-
self.commands = Summary(
74-
f"{METRIC_PREFIX}commands", "Total commands executed"
75-
)
70+
self.latency = Gauge(f"{METRIC_PREFIX}latency", "Latency to Discord", ["shard"])
71+
self.commands = Summary(f"{METRIC_PREFIX}commands", "Total commands executed")
7672
self.version = Info(f"{METRIC_PREFIX}version", "Versions of the bot")
7773
self.features = FeatureCollector(self.bot)
7874

0 commit comments

Comments
 (0)