Run ruff linter with autofixing.

This commit is contained in:
2024-05-22 15:18:44 -04:00
parent 796b052bfc
commit ccbe86623a
22 changed files with 22 additions and 72 deletions
+4 -14
View File
@@ -46,7 +46,6 @@ class ElectionCycle:
config (DakinyConfig): The entire config object.
guild (nextcord.Guild): The guild that this election is running in.
"""
self.config: DakinyConfig = config
self.cycle = cycle
self.election_cycle = self.config.election_cycles[self.cycle]
@@ -69,8 +68,7 @@ class ElectionCycle:
list[str]: A list of message contents in the correct order. Must be a string because the message is too
long.
"""
with open(f"{TEMPLATES_DIR}/election_announcement.txt", mode="r", encoding="utf8") as file:
with open(f"{TEMPLATES_DIR}/election_announcement.txt", encoding="utf8") as file:
message = file.read()
next_election = get_datetime(
@@ -98,8 +96,7 @@ class ElectionCycle:
Returns:
str: Message to send.
"""
with open(f"{TEMPLATES_DIR}/highcouncil_election.txt", mode="r", encoding="utf8") as file:
with open(f"{TEMPLATES_DIR}/highcouncil_election.txt", encoding="utf8") as file:
message = file.read()
return message.format(
@@ -117,8 +114,7 @@ class ElectionCycle:
Returns:
str: Message to send.
"""
with open(f"{TEMPLATES_DIR}/highcouncil_vote.txt", mode="r", encoding="utf8") as file:
with open(f"{TEMPLATES_DIR}/highcouncil_vote.txt", encoding="utf8") as file:
message = file.read()
return message.format(
@@ -133,8 +129,7 @@ class ElectionCycle:
Returns:
str: Message to send
"""
with open(f"{TEMPLATES_DIR}/vote_start.txt", mode="r", encoding="utf8") as file:
with open(f"{TEMPLATES_DIR}/vote_start.txt", encoding="utf8") as file:
message = file.read()
vote_end: datetime = get_datetime(self.config.election_cycles[self.cycle].voting_end)
@@ -226,7 +221,6 @@ class ElectionCycle:
"""
Performs required actions for when voting time has ended.
"""
message = self.build_highcouncil_election_announce()
council_elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
@@ -278,7 +272,6 @@ class ElectionCycle:
"""
Performs required actions for when the highcouncil is elected.
"""
message = self.build_highcouncil_vote_start()
election_thread: nextcord.Thread = self.guild.get_thread(self.get_election_info().ThreadId)
await election_thread.send(message)
@@ -303,7 +296,6 @@ class ElectionCycle:
"""
Marks the election as over.
"""
self.election_over = True
elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
@@ -396,7 +388,6 @@ class ElectionCycle:
Returns:
ElectionInformation: The information from the database about the current election.
"""
with Session(engine) as session:
stmt = select(ElectionInformation).where(
ElectionInformation.ElectionCycle == get_election_name(self.config)
@@ -407,7 +398,6 @@ class ElectionCycle:
"""
Sends a message to general chat reminder clan about election.
"""
general: nextcord.TextChannel = self.guild.get_channel(self.config.params.general_channel_id)
message = f"Reminder to <@&{self.config.params.clan_member_role_id}>! Clan elections are happening! Head over "
+7 -9
View File
@@ -4,8 +4,6 @@
from __future__ import annotations
from typing import List
from pydantic import BaseModel
@@ -29,9 +27,9 @@ class Commit(BaseModel):
committer: Committer
verification: None
timestamp: str
added: List[str]
removed: List[str]
modified: List[str]
added: list[str]
removed: list[str]
modified: list[str]
class HeadCommit(BaseModel):
@@ -42,9 +40,9 @@ class HeadCommit(BaseModel):
committer: Committer
verification: None
timestamp: str
added: List[str]
removed: List[str]
modified: List[str]
added: list[str]
removed: list[str]
modified: list[str]
class Owner(BaseModel):
@@ -187,7 +185,7 @@ class GiteaWebhook(BaseModel):
before: str
after: str
compare_url: str
commits: List[Commit]
commits: list[Commit]
total_commits: int
head_commit: HeadCommit
repository: Repository
-4
View File
@@ -55,7 +55,6 @@ class NominateDMModal(nextcord.ui.Modal):
interaction (Interaction): Interaction with user.
"""
speech = decorate_dm_nomination(interaction.user.id, self.speech.value)
with Session(engine) as session:
@@ -116,7 +115,6 @@ class NominateCLModal(nextcord.ui.Modal):
interaction (Interaction): Interaction with user.
"""
speech = decorate_cl_nomination(interaction.user.id, self.speech.value)
with Session(engine) as session:
@@ -163,7 +161,6 @@ class NominateHighCouncilView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce council elect only
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
await interaction.response.send_message(
@@ -207,7 +204,6 @@ class NominateHighCouncilView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce council elect only
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
await interaction.response.send_message(
-2
View File
@@ -50,7 +50,6 @@ class NominateModal(nextcord.ui.Modal):
interaction (Interaction): Interaction with user.
"""
speech = decorate_nomination(interaction.user.id, self.speech.value)
with Session(engine) as session:
@@ -102,7 +101,6 @@ class NominateView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce members only
if self.guild.get_role(self.config.params.clan_member_role_id) not in interaction.user.roles:
await interaction.response.send_message(
+1 -4
View File
@@ -2,7 +2,6 @@
Contains various views to be used while voting for high council. Controls the logic when performing the vote.
"""
from typing import List
import nextcord
from nextcord import SelectOption
@@ -21,7 +20,7 @@ from utils import VoteType, build_highcouncil_votes_str, get_election_name
class VoteSelect(nextcord.ui.StringSelect):
def __init__(self, options: List["SelectOption"], config: DakinyConfig, election_type: str) -> None:
def __init__(self, options: list["SelectOption"], config: DakinyConfig, election_type: str) -> None:
super().__init__(
placeholder="Choose 1",
min_values=1,
@@ -105,7 +104,6 @@ class VoteHighcouncilView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce council elect only
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
await interaction.response.send_message(
@@ -176,7 +174,6 @@ class VoteHighcouncilView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce council elect only
if self.guild.get_role(self.config.params.clan_council_elect_role_id) not in interaction.user.roles:
await interaction.response.send_message(
+1 -3
View File
@@ -2,7 +2,6 @@
Contains various views to be used while voting. Controls the logic when performing the vote.
"""
from typing import List
import nextcord
from nextcord import SelectOption
@@ -21,7 +20,7 @@ from utils import VoteType, build_votes_str, get_election_name
class VoteSelect(nextcord.ui.StringSelect):
def __init__(self, options: List["SelectOption"], config: DakinyConfig) -> None:
def __init__(self, options: list["SelectOption"], config: DakinyConfig) -> None:
super().__init__(
placeholder="Choose 1",
min_values=1,
@@ -98,7 +97,6 @@ class VoteView(nextcord.ui.View):
button (nextcord.ui.Button): Unused. idk why its needed in the decorator
interaction (nextcord.Interaction): Interaction of user who pressed the button
"""
# enforce members only
if self.guild.get_role(self.config.params.clan_member_role_id) not in interaction.user.roles:
await interaction.response.send_message(