diff --git a/database_setup/create_database.py b/database_setup/create_database.py index 912f729..612f614 100644 --- a/database_setup/create_database.py +++ b/database_setup/create_database.py @@ -1,15 +1,13 @@ -""" -Small script to create the database if it doesn't already exist. -""" +"""Small script to create the database if it doesn't already exist.""" import sqlite3 -from os.path import exists +from pathlib import Path -if not exists("database/dakiny.db"): +if not Path("database/dakiny.db").exists(): with sqlite3.connect("database/dakiny.db") as con: cur = con.cursor() - with open("database_setup/database.sql", encoding="utf-8") as file: + with Path("database_setup/database.sql", encoding="utf-8").open() as file: database_script = file.read() cur.executescript(database_script) con.commit() diff --git a/database_setup/pyproject.toml b/database_setup/pyproject.toml new file mode 100644 index 0000000..e3c5aa1 --- /dev/null +++ b/database_setup/pyproject.toml @@ -0,0 +1,7 @@ +[tool.ruff] +# Extend the `pyproject.toml` file in the parent directory... +extend = "../pyproject.toml" + +[tool.ruff.lint] +# ignore implicit-namespace-package in this directory. +ignore = ["INP001"] diff --git a/database_setup/sql_data_classes.py b/database_setup/sql_data_classes.py index 67411f3..6bdd89c 100644 --- a/database_setup/sql_data_classes.py +++ b/database_setup/sql_data_classes.py @@ -1,6 +1,4 @@ -""" -Simple file to set up the sqlalchemy connection to database. -""" +"""Simple file to set up the sqlalchemy connection to database.""" from sqlalchemy import create_engine from sqlalchemy.ext.automap import automap_base diff --git a/main.py b/main.py index 36e4d99..7aab9bd 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +"""Main file for bot.""" + import logging import os import sys @@ -27,7 +29,13 @@ logger.addHandler(handler) @hydra.main(config_path="conf", config_name="config") -def main(cfg: DakinyConfig): +def main(cfg: DakinyConfig) -> None: + """ + Builds and runs bot. + + Args: + cfg (DakinyConfig): Passed in hydra configuration. + """ # Allows privledged intents for monitoring members joining, roles editing, and role assignments # These need to be enabled in the developer portal as well intents = nextcord.Intents.default() @@ -35,9 +43,6 @@ def main(cfg: DakinyConfig): # Required in order to read messages (eg. prefix commands) intents.message_content = True - # To enable the guilds priveleged intent: - # intents.guilds = True - # To enable the members priveleged intent: intents.members = True @@ -49,15 +54,15 @@ def main(cfg: DakinyConfig): bot.load_extension(f"cogs.{folder}") @bot.listen() - async def on_ready(): - """When Discord is connected""" - assert bot.user is not None - create_database # pylint: disable=pointless-statement + async def on_ready() -> None: + """When Discord is connected.""" + assert bot.user is not None # noqa: S101 documentation does this + create_database # noqa: B018 bot.add_view(NominateView(cfg, bot.get_guild(cfg.params.guild_id))) bot.add_view(NominateHighCouncilView(cfg, bot.get_guild(cfg.params.guild_id))) bot.add_view(VoteView(cfg, bot.get_guild(cfg.params.guild_id))) bot.add_view(VoteHighcouncilView(cfg, bot.get_guild(cfg.params.guild_id))) - print(f"{bot.user.name} has connected to Discord!") + print(f"{bot.user.name} has connected to Discord!") # noqa: T201 TODO make logging to print my stuff to console # Run Discord bot bot.run(bot.config.params.discord_token)