From 53c7e92304945f5bdfea8b4cefb2eeae3248059d Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Sat, 24 Oct 2026 02:38:59 +0200 Subject: [PATCH] lint using new pre-commit --- src/cogs/birthday.py | 18 ++++++----------- src/cogs/galtinn.py | 6 ++---- src/cogs/gullkorn.py | 36 +++++++++++---------------------- src/cogs/mc_whitelist.py | 6 ++---- src/cogs/repeated_messages.py | 8 ++++---- src/cogs/social_credit.py | 12 ++++------- src/cogs/starboard_scraper.py | 18 ++++++----------- src/cogs/streak.py | 24 ++++++++-------------- src/cogs/user_facts.py | 12 ++++------- src/cogs/utils/discord_utils.py | 4 +++- src/cogs/word_cloud.py | 18 ++++++----------- 11 files changed, 57 insertions(+), 105 deletions(-) diff --git a/src/cogs/birthday.py b/src/cogs/birthday.py index 9ce1e56..b966171 100644 --- a/src/cogs/birthday.py +++ b/src/cogs/birthday.py @@ -36,14 +36,12 @@ class Birthday(commands.Cog): Create the necessary tables for the birthday cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS birthdays ( discord_id BIGINT PRIMARY KEY, birthday DATE ); - """ - ) + """) birthday_group = app_commands.Group( name="bursdag", description="Se, endre eller fjern bursdager for brukere på serveren" @@ -59,14 +57,12 @@ class Birthday(commands.Cog): self.bot.logger.info("Checking for birthdays") - self.cursor.execute( - """ + self.cursor.execute(""" SELECT * FROM birthdays WHERE EXTRACT(MONTH FROM birthday) = EXTRACT(MONTH FROM current_date) AND EXTRACT(DAY FROM birthday) = EXTRACT(DAY FROM current_date); - """ - ) + """) birthdays = self.cursor.fetchall() self.bot.logger.info(f"Found the following birthdays: {birthdays}") @@ -192,13 +188,11 @@ class Birthday(commands.Cog): (list[tuple[int, datetime, datetime]]): List of tuples containing the user ID, date of birth and next birthday """ - self.cursor.execute( - """ + self.cursor.execute(""" SELECT *, CAST(birthday + ((EXTRACT(YEAR FROM AGE(birthday)) + 1) * interval '1' YEAR) AS DATE) AS next_bday FROM birthdays ORDER BY next_bday ASC - """ - ) + """) results = self.cursor.fetchall() # Convert date objects to datetime objects diff --git a/src/cogs/galtinn.py b/src/cogs/galtinn.py index 8267158..d0aa11d 100644 --- a/src/cogs/galtinn.py +++ b/src/cogs/galtinn.py @@ -59,14 +59,12 @@ class Galtinn(commands.Cog): data = data.json() if not data["results"]: - embed = embed_templates.error_warning( - """ + embed = embed_templates.error_warning(""" Du har ikke registrert din Discord-konto i Galtinn. Vi lar bare folk med brukere i Galtinn se data. For å koble brukerene dine sammen, besøk [DNS sin Discord](https://discord.gg/SE2ChXjVeV) og skriv: `/galtinn registrer` - """ - ) + """) return await interaction.response.send_message(embed=embed, ephemeral=True) # Only make new request if given user is different from command invoker diff --git a/src/cogs/gullkorn.py b/src/cogs/gullkorn.py index e1fcea0..99ced6f 100644 --- a/src/cogs/gullkorn.py +++ b/src/cogs/gullkorn.py @@ -24,31 +24,25 @@ class Gullkorn(commands.Cog): Create the necessary tables for the gullkorn cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS gullkorn ( discord_id BIGINT PRIMARY KEY, times_cited INT NOT NULL DEFAULT 0, citations_posted INT NOT NULL DEFAULT 0 ); - """ - ) - self.cursor.execute( - """ + """) + self.cursor.execute(""" CREATE OR REPLACE VIEW most_cited AS SELECT discord_id, times_cited FROM gullkorn ORDER BY times_cited DESC; - """ - ) - self.cursor.execute( - """ + """) + self.cursor.execute(""" CREATE OR REPLACE VIEW most_frequent_posters AS SELECT discord_id, citations_posted FROM gullkorn ORDER BY citations_posted DESC; - """ - ) + """) def construct_data_string(self, data: list[tuple[int, int, int]]) -> str: """ @@ -151,30 +145,24 @@ class Gullkorn(commands.Cog): embed.add_field(name="Antall gullkorn postet", value=result[2]) return await interaction.response.send_message(embed=embed, ephemeral=False) - self.cursor.execute( - """ + self.cursor.execute(""" SELECT SUM(citations_posted) FROM gullkorn; - """ - ) + """) summary = self.cursor.fetchone() - self.cursor.execute( - """ + self.cursor.execute(""" SELECT * FROM most_cited LIMIT 5; - """ - ) + """) most_cited = self.cursor.fetchall() - self.cursor.execute( - """ + self.cursor.execute(""" SELECT * FROM most_frequent_posters LIMIT 5; - """ - ) + """) citations_posted = self.cursor.fetchall() most_cited_string = self.construct_data_string(most_cited) diff --git a/src/cogs/mc_whitelist.py b/src/cogs/mc_whitelist.py index 2a0cbfa..89e0a6e 100644 --- a/src/cogs/mc_whitelist.py +++ b/src/cogs/mc_whitelist.py @@ -26,14 +26,12 @@ class MCWhitelist(commands.Cog): Create the necessary tables for the mc_whitelist cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS mc_whitelist ( discord_id BIGINT PRIMARY KEY, minecraft_id TEXT NOT NULL ); - """ - ) + """) whitelist_group = app_commands.Group( name="whitelist", description="Registrer eller fjern deg selv fra vår Minecraft whitelist" diff --git a/src/cogs/repeated_messages.py b/src/cogs/repeated_messages.py index 164442e..9f4436d 100644 --- a/src/cogs/repeated_messages.py +++ b/src/cogs/repeated_messages.py @@ -14,13 +14,13 @@ class RepeatedMessages(commands.Cog): self.bot = bot self.general_channel = 747542544291987597 - #self.fredag.start() - #self.mandag.start() + # self.fredag.start() + # self.mandag.start() self.new_year.start() def cog_unload(self): - #self.fredag.cancel() - #self.mandag.cancel() + # self.fredag.cancel() + # self.mandag.cancel() self.new_year.cancel() @tasks.loop(time=misc_utils.MIDNIGHT) diff --git a/src/cogs/social_credit.py b/src/cogs/social_credit.py index bd0411a..1117b98 100644 --- a/src/cogs/social_credit.py +++ b/src/cogs/social_credit.py @@ -48,14 +48,12 @@ class SocialCredit(commands.Cog): Create the necessary tables for the social credit cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS social_credit ( user_id BIGINT PRIMARY KEY, credit_score SMALLINT NOT NULL ); - """ - ) + """) def add_new_citizen(func): """ @@ -239,12 +237,10 @@ class SocialCredit(commands.Cog): await interaction.response.defer() - self.cursor.execute( - """ + self.cursor.execute(""" SELECT * FROM social_credit ORDER BY credit_score DESC - """ - ) + """) result = self.cursor.fetchall() if not result: diff --git a/src/cogs/starboard_scraper.py b/src/cogs/starboard_scraper.py index d3b1540..22b368a 100644 --- a/src/cogs/starboard_scraper.py +++ b/src/cogs/starboard_scraper.py @@ -34,26 +34,22 @@ class StarboardScraper(commands.Cog): Create the necessary tables for the cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS starboard_messages ( id SERIAL PRIMARY KEY, starboard_message_id BIGINT UNIQUE, original_message_id BIGINT, original_channel_id BIGINT ) - """ - ) - self.cursor.execute( - """ + """) + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS starboard_scraper_state ( id INTEGER PRIMARY KEY DEFAULT 1, last_scraped_message_id BIGINT, last_scrape_time TIMESTAMP, CHECK (id = 1) ) - """ - ) + """) def get_last_scraped_message_id(self): """ @@ -63,13 +59,11 @@ class StarboardScraper(commands.Cog): ------- int or None: Last scraped message ID or None if never scraped """ - self.cursor.execute( - """ + self.cursor.execute(""" SELECT last_scraped_message_id FROM starboard_scraper_state WHERE id = 1 - """ - ) + """) result = self.cursor.fetchone() return result[0] if result else None diff --git a/src/cogs/streak.py b/src/cogs/streak.py index d16775c..62c199d 100644 --- a/src/cogs/streak.py +++ b/src/cogs/streak.py @@ -38,16 +38,14 @@ class Streak(commands.Cog): Create the necessary tables for the streak cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS streak ( discord_id BIGINT PRIMARY KEY, streak_start_id TEXT NOT NULL, streak_start_time timestamp NOT NULL, latest_post_time timestamp NOT NULL ); - """ - ) + """) async def cog_unload(self): self.bot.logger.info("Unloading cog") @@ -60,12 +58,10 @@ class Streak(commands.Cog): Populate the cache with the current streaks """ - self.cursor.execute( - """ + self.cursor.execute(""" SELECT * FROM streak; - """ - ) + """) streaks = self.cursor.fetchall() for streak in streaks: @@ -149,12 +145,10 @@ class Streak(commands.Cog): if self.streak_cache: await self.insert_cache() - self.cursor.execute( - """ + self.cursor.execute(""" SELECT discord_id, latest_post_time FROM streak; - """ - ) + """) streaks = self.cursor.fetchall() for streak in streaks: @@ -250,13 +244,11 @@ class Streak(commands.Cog): await interaction.response.defer() - self.cursor.execute( - """ + self.cursor.execute(""" SELECT discord_id, streak_start_time FROM streak ORDER BY streak_start_time; - """ - ) + """) streaks = self.cursor.fetchall() if not streaks: diff --git a/src/cogs/user_facts.py b/src/cogs/user_facts.py index 8639bfd..3e83700 100644 --- a/src/cogs/user_facts.py +++ b/src/cogs/user_facts.py @@ -41,15 +41,13 @@ class UserFacts(commands.Cog): Create the necessary tables for the birthday cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS user_facts ( discord_id BIGINT PRIMARY KEY, mbti CHAR(4), height INT ); - """ - ) + """) height_group = app_commands.Group(name="høyde", description="Se, endre eller fjern høyde for brukere på serveren") @@ -162,13 +160,11 @@ class UserFacts(commands.Cog): interaction (discord.Interaction): The interaction object """ - self.cursor.execute( - """ + self.cursor.execute(""" SELECT discord_id, height FROM user_facts WHERE height IS NOT NULL ORDER BY height DESC; - """ - ) + """) if not (result := self.cursor.fetchall()): return await interaction.response.send_message( diff --git a/src/cogs/utils/discord_utils.py b/src/cogs/utils/discord_utils.py index 41b7010..3bbc199 100644 --- a/src/cogs/utils/discord_utils.py +++ b/src/cogs/utils/discord_utils.py @@ -305,7 +305,9 @@ class _KickSelectMenu(discord.ui.Select): def __init__(self, parent_view: LobbyView): self.parent_view = parent_view options = [ - discord.SelectOption(label=p.display_name, value=str(p.id), emoji="🔨", description=f"Kick {p.display_name}") + discord.SelectOption( + label=p.display_name, value=str(p.id), emoji="🔨", description=f"Kick {p.display_name}" + ) for p in self.parent_view.lobby.players ] super().__init__(placeholder="Kick en spiller", max_values=1, min_values=1, options=options) diff --git a/src/cogs/word_cloud.py b/src/cogs/word_cloud.py index 93f5e55..dd15493 100644 --- a/src/cogs/word_cloud.py +++ b/src/cogs/word_cloud.py @@ -55,25 +55,21 @@ class WordCloud(commands.Cog): Create the necessary tables for the Ordsky cog to work """ - self.cursor.execute( - """ + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS wordcloud_metadata ( discord_user_id BIGINT PRIMARY KEY, tracked_since_message_channel_id BIGINT NOT NULL, tracked_since_message_id BIGINT NOT NULL UNIQUE ) - """ - ) - self.cursor.execute( - """ + """) + self.cursor.execute(""" CREATE TABLE IF NOT EXISTS wordcloud_words ( discord_user_id BIGINT NOT NULL, word TEXT NOT NULL, frequency INTEGER NOT NULL, PRIMARY KEY (discord_user_id, word) ) - """ - ) + """) async def cog_unload(self): """ @@ -89,12 +85,10 @@ class WordCloud(commands.Cog): Populates the cached list of consenting users """ - self.cursor.execute( - """ + self.cursor.execute(""" SELECT discord_user_id FROM wordcloud_metadata - """ - ) + """) self.consenting_users = [row[0] for row in self.cursor.fetchall()] async def insert_cache(self):