diff --git a/backend/oasst_backend/prompt_repository.py b/backend/oasst_backend/prompt_repository.py index 13c6cd23..0a6c193c 100644 --- a/backend/oasst_backend/prompt_repository.py +++ b/backend/oasst_backend/prompt_repository.py @@ -7,7 +7,14 @@ import oasst_backend.models.db_payload as db_payload from loguru import logger from oasst_backend.exceptions import OasstError, OasstErrorCode from oasst_backend.journal_writer import JournalWriter -from oasst_backend.models import ApiClient, Person, Post, PostReaction, TextLabels, WorkPackage +from oasst_backend.models import ( + ApiClient, + Person, + Post, + PostReaction, + TextLabels, + WorkPackage, +) from oasst_backend.models.payload_column_type import PayloadContainer from oasst_shared.schemas import protocol as protocol_schema from sqlmodel import Session, func diff --git a/discord-bot/.env.example b/discord-bot/.env.example index c518010d..7c414a53 100644 --- a/discord-bot/.env.example +++ b/discord-bot/.env.example @@ -1,4 +1,4 @@ TOKEN= DECLARE_GLOBAL_COMMANDS= OWNER_IDS= -PREFIX="./" \ No newline at end of file +PREFIX="./" diff --git a/discord-bot/.gitignore b/discord-bot/.gitignore index 499012d2..ee1e23f2 100644 --- a/discord-bot/.gitignore +++ b/discord-bot/.gitignore @@ -7,4 +7,4 @@ __pycache__/ .env # Database files -*.db \ No newline at end of file +*.db diff --git a/discord-bot/bot/__init__.py b/discord-bot/bot/__init__.py index 3d04718d..66779a9c 100644 --- a/discord-bot/bot/__init__.py +++ b/discord-bot/bot/__init__.py @@ -1,2 +1,2 @@ -# -*- coding=utf-8 -*- +# -*- coding: utf-8 -*- """The official Open-Assistant Discord Bot.""" diff --git a/discord-bot/bot/__main__.py b/discord-bot/bot/__main__.py index f258d148..87032e40 100644 --- a/discord-bot/bot/__main__.py +++ b/discord-bot/bot/__main__.py @@ -1,4 +1,4 @@ -# -*- coding=utf-8 -*- +# -*- coding: utf-8 -*- """Entry point for the bot.""" import logging import os diff --git a/discord-bot/bot/bot.py b/discord-bot/bot/bot.py index 9b443986..1f801413 100644 --- a/discord-bot/bot/bot.py +++ b/discord-bot/bot/bot.py @@ -1,4 +1,4 @@ -# -*- coding=utf-8 -*- +# -*- coding: utf-8 -*- """Bot logic.""" import aiosqlite import hikari @@ -26,7 +26,7 @@ async def on_starting(event: hikari.StartingEvent): miru.install(bot) # component handler bot.load_extensions_from("./bot/extensions") # load extensions - bot.d.db = await aiosqlite.connect("./bot/db/database.db") # TODO: Update + bot.d.db = await aiosqlite.connect("./bot/db/database.db") await bot.d.db.executescript(open("./bot/db/schema.sql").read()) await bot.d.db.commit() diff --git a/discord-bot/bot/config.py b/discord-bot/bot/config.py index e3addac9..fafcb308 100644 --- a/discord-bot/bot/config.py +++ b/discord-bot/bot/config.py @@ -1,11 +1,11 @@ -# -*- coding=utf-8 -*- +# -*- coding: utf-8 -*- """Configuration for the bot.""" import logging from dataclasses import dataclass from os import getenv -from dotenv import load_dotenv +from dotenv import load_dotenv # type: ignore load_dotenv() diff --git a/discord-bot/bot/db/schemas.py b/discord-bot/bot/db/schemas.py index efb903b8..9c548e9f 100644 --- a/discord-bot/bot/db/schemas.py +++ b/discord-bot/bot/db/schemas.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- """Database schemas.""" -from aiosqlite import Row, Connection -from pydantic import BaseModel import typing as t +from aiosqlite import Connection, Row +from pydantic import BaseModel + class GuildSettings(BaseModel): """Guild settings.""" diff --git a/discord-bot/bot/extensions/_example.py b/discord-bot/bot/extensions/_example.py index 37783e43..76398881 100644 --- a/discord-bot/bot/extensions/_example.py +++ b/discord-bot/bot/extensions/_example.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # TODO: Convert file to markdown # -*- coding: utf-8 -*- """Example plugin for reference. diff --git a/discord-bot/bot/extensions/text_labels.py b/discord-bot/bot/extensions/text_labels.py index 325929d2..48e32763 100644 --- a/discord-bot/bot/extensions/text_labels.py +++ b/discord-bot/bot/extensions/text_labels.py @@ -8,13 +8,14 @@ import lightbulb import miru from aiosqlite import Connection +from bot.db.schemas import GuildSettings +from bot.utils import EMPTY + plugin = lightbulb.Plugin( "TextLabels", ) plugin.add_checks(lightbulb.guild_only) # Context menus are only enabled in guilds -from bot.utils import EMPTY -from bot.db.schemas import GuildSettings DISCORD_GRAY = 0x2F3136 diff --git a/discord-bot/bot/extensions/work.py b/discord-bot/bot/extensions/work.py index 1c1f38de..ecbe1710 100644 --- a/discord-bot/bot/extensions/work.py +++ b/discord-bot/bot/extensions/work.py @@ -4,18 +4,18 @@ import asyncio import logging import typing as t from datetime import datetime -from aiosqlite import Connection import hikari import lightbulb import lightbulb.decorators import miru +from aiosqlite import Connection from oasst_shared.schemas import protocol as protocol_schema from oasst_shared.schemas.protocol import TaskRequestType from bot.api_client import OasstApiClient, TaskType -from bot.utils import EMPTY from bot.db.schemas import GuildSettings +from bot.utils import EMPTY plugin = lightbulb.Plugin("WorkPlugin") @@ -76,7 +76,7 @@ async def _handle_task(ctx: lightbulb.SlashContext, task_type: TaskRequestType) ) except asyncio.TimeoutError: await ctx.author.send("Task timed out. Exiting") - # TODO: NACK task maybe? + await oasst_api.nack_task(task.id, reason="timed out") return # Invalid response diff --git a/discord-bot/dev-requirements.txt b/discord-bot/dev-requirements.txt index 44a8d2cc..56393fdd 100644 --- a/discord-bot/dev-requirements.txt +++ b/discord-bot/dev-requirements.txt @@ -1,8 +1,8 @@ -nox black -isort codespell flake8 -pyright \ No newline at end of file +isort +nox +pyright diff --git a/discord-bot/flake8-requirements.txt b/discord-bot/flake8-requirements.txt index 3509207e..a022d8c5 100644 --- a/discord-bot/flake8-requirements.txt +++ b/discord-bot/flake8-requirements.txt @@ -1,8 +1,4 @@ flake8==6.0.0 - -# Plugins - -Flake8-pyproject # use the pyproject.toml as the config file flake8-bandit # runs bandit flake8-black # runs black # flake8-broken-line # forbey "\" linebreaks @@ -21,6 +17,10 @@ flake8-mutable # mutable default argument detection flake8-pep3101 # new-style format strings only flake8-print # complain about print statements in code flake8-printf-formatting # forbey printf-style python2 string formatting + +# Plugins + +Flake8-pyproject # use the pyproject.toml as the config file flake8-pytest-style # pytest checks flake8-raise # exception raising linting flake8-use-fstring # format string checking diff --git a/discord-bot/message_templates.py b/discord-bot/message_templates.py index dcb84c94..256f93d3 100644 --- a/discord-bot/message_templates.py +++ b/discord-bot/message_templates.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- """Message templates for the discord bot.""" -import jinja2 import typing + +import jinja2 from loguru import logger diff --git a/discord-bot/noxfile.py b/discord-bot/noxfile.py index f85fc60c..891e87fb 100644 --- a/discord-bot/noxfile.py +++ b/discord-bot/noxfile.py @@ -1,4 +1,4 @@ -# -*- coding=utf-8 -*- +# -*- coding: utf-8 -*- """Automated linting, formatting, and typechecking.""" import nox from nox.sessions import Session diff --git a/discord-bot/requirements.txt b/discord-bot/requirements.txt index 17348c12..62b9b931 100644 --- a/discord-bot/requirements.txt +++ b/discord-bot/requirements.txt @@ -1,11 +1,11 @@ -hikari # discord framework -hikari[speedups] -uvloop; os_name != 'nt' -hikari-lightbulb # command handler -hikari-miru # modals and buttons - -python-dotenv # .env file support -aiosqlite # database aiohttp # http client aiohttp[speedups] # speedups for aiohttp -loguru \ No newline at end of file +aiosqlite # database +hikari # discord framework +hikari-lightbulb # command handler +hikari-miru # modals and buttons +hikari[speedups] +loguru + +python-dotenv # .env file support +uvloop; os_name != 'nt'