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
+3 -11
View File
@@ -3,9 +3,9 @@ File contains util functions.
"""
import os
from collections.abc import Sequence
from datetime import datetime
from enum import StrEnum
from typing import Sequence
import nextcord
from sqlalchemy import select, true, update
@@ -63,7 +63,6 @@ def get_election_name(config: DakinyConfig) -> str:
Returns:
str: the name of the election cycle
"""
cycle = get_current_election_cycle(config)
current_cycle = config.election_cycles[cycle]
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
@@ -79,7 +78,6 @@ def get_quarter_name(config: DakinyConfig) -> str:
Returns:
str: the name of the cycle.
"""
cycle = get_quarter_cycle(config)
current_cycle = config.election_cycles[cycle]
@@ -96,7 +94,6 @@ def get_current_election_cycle(config: DakinyConfig) -> int:
Returns:
int: cycle index for active election. None for no active cycle
"""
today = datetime.today()
for cycle, election in enumerate(config.election_cycles):
@@ -120,7 +117,6 @@ def get_quarter_cycle(config: DakinyConfig) -> int:
Returns:
int: cycle index for current cycle.
"""
today = datetime.today()
for cycle, election in enumerate(config.election_cycles):
if (
@@ -143,7 +139,6 @@ def build_votes_str(config: DakinyConfig, guild: nextcord.Guild) -> str:
Returns:
str: String that contains all nominees and their votes.
"""
votes: dict[int, int] = {}
election_name = get_election_name(config)
@@ -180,7 +175,6 @@ def build_highcouncil_votes_str(config: DakinyConfig, guild: nextcord.Guild) ->
str: String that contains all nominees and their votes.
guild (nextcord.Guild): The guild object. Used to get display names for sorting.
"""
cl_votes: dict[int, int] = {}
dm_votes: dict[int, int] = {}
@@ -315,7 +309,6 @@ def record_event_points(config: DakinyConfig, users: Sequence[str], is_member: b
is_member (bool): whether the users are a discord member or not
points (int): number of points to add
"""
quarter_name = get_quarter_name(config)
with Session(engine) as session:
for user in users:
@@ -395,7 +388,6 @@ async def update_clan_messages(guild: nextcord.Guild, channel_updates: Sequence[
guild (nextcord.Guild): Guild object that all channels and messages belong to.
channel_updates: (Sequence[str]): a sequence of the channels to update.
"""
dirs = [dir_name for dir_name in channel_updates if os.path.isdir(f"{MESSAGES_DIR}/{dir_name}")]
with Session(engine) as session:
@@ -410,7 +402,7 @@ async def update_clan_messages(guild: nextcord.Guild, channel_updates: Sequence[
for file_name in sorted_files:
message_name = f"{dir_name}/{file_name}"
file_path = f"{dir_path}/{file_name}"
with open(file_path, "r", encoding="utf8") as reader:
with open(file_path, encoding="utf8") as reader:
await edit_clan_message(session, channel, message_name, reader.read(2000))
@@ -536,7 +528,7 @@ async def edit_clan_council_info(guild: nextcord.Guild, config: DakinyConfig):
quarter = get_quarter_name(config)
with open(f"{TEMPLATES_DIR}/council_members.txt", mode="r", encoding="utf8") as file:
with open(f"{TEMPLATES_DIR}/council_members.txt", encoding="utf8") as file:
message = file.read()
message = message.format(
quarter=quarter,