pre-commit changes

This commit is contained in:
Alex Ott
2022-12-30 04:12:54 -08:00
parent 98955441d1
commit 65c078fb9f
16 changed files with 45 additions and 34 deletions
+8 -1
View File
@@ -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
+1 -1
View File
@@ -1,4 +1,4 @@
TOKEN=<discord bot token>
DECLARE_GLOBAL_COMMANDS=<testing guild id>
OWNER_IDS=<your user id>
PREFIX="./"
PREFIX="./"
+1 -1
View File
@@ -7,4 +7,4 @@ __pycache__/
.env
# Database files
*.db
*.db
+1 -1
View File
@@ -1,2 +1,2 @@
# -*- coding=utf-8 -*-
# -*- coding: utf-8 -*-
"""The official Open-Assistant Discord Bot."""
+1 -1
View File
@@ -1,4 +1,4 @@
# -*- coding=utf-8 -*-
# -*- coding: utf-8 -*-
"""Entry point for the bot."""
import logging
import os
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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()
+3 -2
View File
@@ -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."""
+1
View File
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# TODO: Convert file to markdown
# -*- coding: utf-8 -*-
"""Example plugin for reference.
+3 -2
View File
@@ -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
+3 -3
View File
@@ -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
+3 -3
View File
@@ -1,8 +1,8 @@
nox
black
isort
codespell
flake8
pyright
isort
nox
pyright
+4 -4
View File
@@ -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
+2 -1
View File
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
"""Message templates for the discord bot."""
import jinja2
import typing
import jinja2
from loguru import logger
+1 -1
View File
@@ -1,4 +1,4 @@
# -*- coding=utf-8 -*-
# -*- coding: utf-8 -*-
"""Automated linting, formatting, and typechecking."""
import nox
from nox.sessions import Session
+9 -9
View File
@@ -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
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'