From d6f9cd05de6844a9c3901aab68fdecef3095695e Mon Sep 17 00:00:00 2001 From: hypergonial <46067571+hypergonial@users.noreply.github.com> Date: Sun, 17 Dec 2023 16:00:35 +0100 Subject: [PATCH] Fix imports --- Dockerfile | 2 +- docker-compose.yml | 2 +- src/{main.py => __main__.py} | 8 ++++--- config_example.py => src/config_example.py | 0 src/db/migrations/7.py | 11 ++++----- src/etc/settings_static.py | 3 ++- src/extensions/annoverse.py | 12 +++++----- src/extensions/automod.py | 17 +++++++------- src/extensions/command_handler.py | 17 +++++++------- src/extensions/dev.py | 11 ++++----- src/extensions/fallingfrontier.py | 10 ++++----- src/extensions/fandom.py | 10 ++++----- src/extensions/fun.py | 23 ++++++++++--------- src/extensions/help.py | 9 ++++---- src/extensions/misc.py | 15 +++++++------ src/extensions/moderation.py | 25 +++++++++++---------- src/extensions/reminders.py | 13 ++++++----- src/extensions/reports.py | 13 ++++++----- src/extensions/role_buttons.py | 15 +++++++------ src/extensions/settings.py | 26 ++++++++++++---------- src/extensions/starboard.py | 13 ++++++----- src/extensions/tags.py | 11 ++++----- src/extensions/test.py | 7 +++--- src/extensions/troubleshooter.py | 9 ++++---- src/extensions/userlog.py | 13 ++++++----- src/models/audit_log.py | 2 +- src/models/bot.py | 19 ++++++++-------- src/models/checks.py | 7 +++--- src/models/context.py | 4 ++-- src/models/db.py | 7 +++--- src/models/db_user.py | 5 +++-- src/models/events.py | 6 ++--- src/models/journal.py | 5 +++-- src/models/mod_actions.py | 19 ++++++++-------- src/models/plugin.py | 2 +- src/models/rolebutton.py | 5 +++-- src/models/settings.py | 2 +- src/models/starboard.py | 2 +- src/models/tag.py | 5 +++-- src/models/views.py | 19 ++++++++-------- src/utils/cache.py | 5 +++-- src/utils/helpers.py | 13 ++++++----- src/utils/scheduler.py | 9 ++++---- 43 files changed, 230 insertions(+), 201 deletions(-) rename src/{main.py => __main__.py} (90%) rename config_example.py => src/config_example.py (100%) diff --git a/Dockerfile b/Dockerfile index 36f6e5c..0f5cba9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,4 +17,4 @@ RUN poetry config virtualenvs.create false RUN poetry install -n --only main COPY . ./ -CMD ["python3.11", "-O", "main.py"] \ No newline at end of file +CMD ["python3.11", "-O", "-m", "src"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7a94085..6a84f2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: dockerfile: Dockerfile args: postgres_version: ${POSTGRES_VERSION:-14} - command: ["python3.11", "-O", "main.py"] + command: ["python3.11", "-O", "-m", "src"] depends_on: - sned-db restart: always diff --git a/src/main.py b/src/__main__.py similarity index 90% rename from src/main.py rename to src/__main__.py index 3bd9cd4..57adc1d 100755 --- a/src/main.py +++ b/src/__main__.py @@ -2,19 +2,21 @@ import logging import os +import pathlib import platform import re -from models import SnedBot +from src.models import SnedBot DOTENV_REGEX = re.compile(r"^(?P[A-Za-z_]+[A-Za-z0-9_]*)=(?P[^#]+)(#.*)?$") +BASE_DIR = str(pathlib.Path(os.path.abspath(__file__)).parents[1]) if int(platform.python_version_tuple()[1]) < 10: logging.fatal("Python version must be 3.10 or greater! Exiting...") exit(1) try: - with open(".env") as env: + with open(os.path.join(BASE_DIR, ".env")) as env: for line in env.readlines(): match = DOTENV_REGEX.match(line) if not match: @@ -25,7 +27,7 @@ logging.info(".env file not found, using secrets from the environment instead.") try: - from config import Config + from .config import Config except ImportError: logging.fatal( "Failed loading configuration. Please make sure 'config.py' exists in the root directory of the project and contains valid data." diff --git a/config_example.py b/src/config_example.py similarity index 100% rename from config_example.py rename to src/config_example.py diff --git a/src/db/migrations/7.py b/src/db/migrations/7.py index 0612681..821f0f7 100644 --- a/src/db/migrations/7.py +++ b/src/db/migrations/7.py @@ -7,10 +7,11 @@ import hikari import lightbulb -from models import JournalEntry, JournalEntryType + +from src.models import JournalEntry, JournalEntryType if t.TYPE_CHECKING: - from models.db import Database + from src.models.db import Database NOTE_REGEX = re.compile( r"\d+):\w>: (?P.+) \*\*(?P.+) (?:by|for) (?P.+):\*\* (?P.*)" @@ -72,9 +73,9 @@ async def _migrate_notes(db: Database) -> None: records = await db.fetch("SELECT * FROM users") for record in records: - notes: list[str] = record.get("notes") - user_id: int = record.get("user_id") - guild_id: int = record.get("guild_id") + notes: list[str] = record["notes"] + user_id: int = record["user_id"] + guild_id: int = record["guild_id"] if not notes: continue for note in notes: diff --git a/src/etc/settings_static.py b/src/etc/settings_static.py index 0ebebf1..c49c760 100644 --- a/src/etc/settings_static.py +++ b/src/etc/settings_static.py @@ -1,6 +1,7 @@ import hikari import miru -from models.mod_actions import ModerationFlags + +from src.models.mod_actions import ModerationFlags # Static values for the settings extension diff --git a/src/extensions/annoverse.py b/src/extensions/annoverse.py index c12fe82..ac52af0 100644 --- a/src/extensions/annoverse.py +++ b/src/extensions/annoverse.py @@ -1,12 +1,12 @@ -import etc.const as const import hikari import lightbulb -from models.bot import SnedBot -from models.context import SnedContext -from models.plugin import SnedPlugin -from utils import helpers -from config import Config +import src.etc.const as const +from src.config import Config +from src.models.bot import SnedBot +from src.models.context import SnedContext +from src.models.plugin import SnedPlugin +from src.utils import helpers annoverse = SnedPlugin("Annoverse") annoverse.default_enabled_guilds = Config().DEBUG_GUILDS or (372128553031958529,) diff --git a/src/extensions/automod.py b/src/extensions/automod.py index c5e2370..762f670 100644 --- a/src/extensions/automod.py +++ b/src/extensions/automod.py @@ -8,14 +8,15 @@ import hikari import kosu import lightbulb -import utils -from etc import const -from etc.settings_static import default_automod_policies, notices -from models.bot import SnedBot -from models.events import AutoModMessageFlagEvent -from models.plugin import SnedPlugin -from utils import helpers -from utils.ratelimiter import MemberBucket + +import src.utils as utils +from src.etc import const +from src.etc.settings_static import default_automod_policies, notices +from src.models.bot import SnedBot +from src.models.events import AutoModMessageFlagEvent +from src.models.plugin import SnedPlugin +from src.utils import helpers +from src.utils.ratelimiter import MemberBucket INVITE_REGEX = re.compile(r"(?:https?://)?discord(?:app)?\.(?:com/invite|gg)/[a-zA-Z0-9]+/?") """Used to detect and handle Discord invites.""" diff --git a/src/extensions/command_handler.py b/src/extensions/command_handler.py index fd6df63..c1f9144 100644 --- a/src/extensions/command_handler.py +++ b/src/extensions/command_handler.py @@ -8,22 +8,23 @@ import hikari import lightbulb -from etc import const -from etc.perms_str import get_perm_str -from models.bot import SnedBot -from models.context import SnedPrefixContext, SnedSlashContext -from models.errors import ( + +from src.etc import const +from src.etc.perms_str import get_perm_str +from src.models.bot import SnedBot +from src.models.context import SnedPrefixContext, SnedSlashContext +from src.models.errors import ( BotRoleHierarchyError, InteractionTimeOutError, MemberExpectedError, RoleHierarchyError, UserBlacklistedError, ) -from models.plugin import SnedPlugin -from utils import helpers +from src.models.plugin import SnedPlugin +from src.utils import helpers if TYPE_CHECKING: - from models import SnedContext + from src.models import SnedContext logger = logging.getLogger(__name__) diff --git a/src/extensions/dev.py b/src/extensions/dev.py index d5f9cf5..d42d57e 100644 --- a/src/extensions/dev.py +++ b/src/extensions/dev.py @@ -10,12 +10,13 @@ import hikari import lightbulb import miru -from etc import const from miru.ext import nav -from models import AuthorOnlyNavigator, SnedPrefixContext -from models.bot import SnedBot -from models.plugin import SnedPlugin -from models.views import AuthorOnlyView + +from src.etc import const +from src.models import AuthorOnlyNavigator, SnedPrefixContext +from src.models.bot import SnedBot +from src.models.plugin import SnedPlugin +from src.models.views import AuthorOnlyView logger = logging.getLogger(__name__) diff --git a/src/extensions/fallingfrontier.py b/src/extensions/fallingfrontier.py index 0f8a0bf..826ec56 100644 --- a/src/extensions/fallingfrontier.py +++ b/src/extensions/fallingfrontier.py @@ -1,12 +1,12 @@ import hikari import lightbulb import miru -from etc import const -from models.bot import SnedBot -from models.context import SnedSlashContext -from models.plugin import SnedPlugin -from config import Config +from src.config import Config +from src.etc import const +from src.models.bot import SnedBot +from src.models.context import SnedSlashContext +from src.models.plugin import SnedPlugin TESTER_STAGING_ROLE = 971843694896513074 TESTER_STAGING_CHANNEL = 971844463884382259 diff --git a/src/extensions/fandom.py b/src/extensions/fandom.py index fb88aa9..00040ca 100644 --- a/src/extensions/fandom.py +++ b/src/extensions/fandom.py @@ -1,12 +1,12 @@ import hikari import lightbulb import yarl -from etc import const -from models.bot import SnedBot -from models.context import SnedSlashContext -from models.plugin import SnedPlugin -from config import Config +from src.config import Config +from src.etc import const +from src.models.bot import SnedBot +from src.models.context import SnedSlashContext +from src.models.plugin import SnedPlugin fandom = SnedPlugin("Fandom") diff --git a/src/extensions/fun.py b/src/extensions/fun.py index b692299..cf8c828 100644 --- a/src/extensions/fun.py +++ b/src/extensions/fun.py @@ -13,20 +13,21 @@ import Levenshtein as lev # noqa: N813 import lightbulb import miru -from etc import const from miru.ext import nav -from models import SnedBot, SnedSlashContext -from models.checks import bot_has_permissions -from models.context import SnedContext, SnedUserContext -from models.plugin import SnedPlugin -from models.views import AuthorOnlyNavigator, AuthorOnlyView from PIL import Image, ImageDraw, ImageFont -from utils import GlobalBucket, RateLimiter, helpers -from utils.dictionaryapi import DictionaryClient, DictionaryEntry, DictionaryError, UrbanEntry -from utils.ratelimiter import UserBucket -from utils.rpn import InvalidExpressionError, Solver -from config import Config +from src.etc import const +from src.models import SnedBot, SnedSlashContext +from src.models.checks import bot_has_permissions +from src.models.context import SnedContext, SnedUserContext +from src.models.plugin import SnedPlugin +from src.models.views import AuthorOnlyNavigator, AuthorOnlyView +from src.utils import GlobalBucket, RateLimiter, helpers +from src.utils.dictionaryapi import DictionaryClient, DictionaryEntry, DictionaryError, UrbanEntry +from src.utils.ratelimiter import UserBucket +from src.utils.rpn import InvalidExpressionError, Solver + +from ..config import Config if TYPE_CHECKING: from fractions import Fraction diff --git a/src/extensions/help.py b/src/extensions/help.py index 4857cfc..b1e2490 100644 --- a/src/extensions/help.py +++ b/src/extensions/help.py @@ -2,14 +2,15 @@ import typing as t -import etc.const as const import hikari import lightbulb -from models.plugin import SnedPlugin + +import src.etc.const as const +from src.models.plugin import SnedPlugin if t.TYPE_CHECKING: - from models import SnedBot - from models.context import SnedSlashContext + from src.models import SnedBot + from src.models.context import SnedSlashContext help = SnedPlugin("Help") diff --git a/src/extensions/misc.py b/src/extensions/misc.py index 7453f6e..da3a2d7 100644 --- a/src/extensions/misc.py +++ b/src/extensions/misc.py @@ -7,13 +7,14 @@ import miru import psutil import pytz -from etc import const -from models import SnedBot -from models.checks import bot_has_permissions -from models.context import SnedMessageContext, SnedSlashContext -from models.plugin import SnedPlugin -from utils import helpers -from utils.scheduler import ConversionMode + +from src.etc import const +from src.models import SnedBot +from src.models.checks import bot_has_permissions +from src.models.context import SnedMessageContext, SnedSlashContext +from src.models.plugin import SnedPlugin +from src.utils import helpers +from src.utils.scheduler import ConversionMode logger = logging.getLogger(__name__) diff --git a/src/extensions/moderation.py b/src/extensions/moderation.py index 0e0481f..1b508c9 100644 --- a/src/extensions/moderation.py +++ b/src/extensions/moderation.py @@ -5,18 +5,19 @@ import hikari import lightbulb import miru -import models -from etc import const -from models import errors -from models.bot import SnedBot -from models.checks import bot_has_permissions, is_above_target, is_invoker_above_target -from models.context import SnedSlashContext, SnedUserContext -from models.db_user import DatabaseUser -from models.events import MassBanEvent -from models.journal import JournalEntry, JournalEntryType -from models.mod_actions import ModerationFlags -from models.plugin import SnedPlugin -from utils import helpers + +import src.models as models +from src.etc import const +from src.models import errors +from src.models.bot import SnedBot +from src.models.checks import bot_has_permissions, is_above_target, is_invoker_above_target +from src.models.context import SnedSlashContext, SnedUserContext +from src.models.db_user import DatabaseUser +from src.models.events import MassBanEvent +from src.models.journal import JournalEntry, JournalEntryType +from src.models.mod_actions import ModerationFlags +from src.models.plugin import SnedPlugin +from src.utils import helpers logger = logging.getLogger(__name__) diff --git a/src/extensions/reminders.py b/src/extensions/reminders.py index ab50340..172baf3 100644 --- a/src/extensions/reminders.py +++ b/src/extensions/reminders.py @@ -6,12 +6,13 @@ import hikari import lightbulb import miru -from etc import const -from models import SnedBot, SnedSlashContext, Timer, events -from models.plugin import SnedPlugin -from models.timer import TimerEvent -from models.views import AuthorOnlyNavigator -from utils import helpers + +from src.etc import const +from src.models import SnedBot, SnedSlashContext, Timer, events +from src.models.plugin import SnedPlugin +from src.models.timer import TimerEvent +from src.models.views import AuthorOnlyNavigator +from src.utils import helpers reminders = SnedPlugin(name="Reminders") diff --git a/src/extensions/reports.py b/src/extensions/reports.py index 40ba4c2..30903b2 100644 --- a/src/extensions/reports.py +++ b/src/extensions/reports.py @@ -3,12 +3,13 @@ import hikari import lightbulb import miru -from etc import const -from models import SnedSlashContext -from models.bot import SnedBot -from models.context import SnedApplicationContext, SnedContext, SnedMessageContext, SnedUserContext -from models.plugin import SnedPlugin -from utils import helpers + +from src.etc import const +from src.models import SnedSlashContext +from src.models.bot import SnedBot +from src.models.context import SnedApplicationContext, SnedContext, SnedMessageContext, SnedUserContext +from src.models.plugin import SnedPlugin +from src.utils import helpers logger = logging.getLogger(__name__) diff --git a/src/extensions/role_buttons.py b/src/extensions/role_buttons.py index a72dd8f..7e692dc 100644 --- a/src/extensions/role_buttons.py +++ b/src/extensions/role_buttons.py @@ -4,13 +4,14 @@ import hikari import lightbulb import miru -import models -from etc import const -from models import SnedBot, SnedSlashContext -from models.plugin import SnedPlugin -from models.rolebutton import RoleButton, RoleButtonMode -from utils import helpers -from utils.ratelimiter import MemberBucket, RateLimiter + +import src.models as models +from src.etc import const +from src.models import SnedBot, SnedSlashContext +from src.models.plugin import SnedPlugin +from src.models.rolebutton import RoleButton, RoleButtonMode +from src.utils import helpers +from src.utils.ratelimiter import MemberBucket, RateLimiter logger = logging.getLogger(__name__) diff --git a/src/extensions/settings.py b/src/extensions/settings.py index 3a6d371..5ec4bda 100644 --- a/src/extensions/settings.py +++ b/src/extensions/settings.py @@ -10,9 +10,10 @@ import hikari import lightbulb import miru -import models -from etc import const -from etc.settings_static import ( + +import src.models as models +from src.etc import const +from src.etc.settings_static import ( log_event_strings, mod_flags_strings, policy_fields, @@ -21,12 +22,12 @@ policy_text_inputs, settings_help, ) -from extensions.userlog import LogEvent -from models.bot import SnedBot -from models.checks import bot_has_permissions -from models.mod_actions import ModerationFlags -from models.plugin import SnedPlugin -from models.settings import ( +from src.extensions.userlog import LogEvent +from src.models.bot import SnedBot +from src.models.checks import bot_has_permissions +from src.models.mod_actions import ModerationFlags +from src.models.plugin import SnedPlugin +from src.models.settings import ( BackButton, BooleanButton, DoneButton, @@ -39,12 +40,13 @@ QuitButton, SettingValue, ) -from models.starboard import StarboardSettings -from utils import helpers +from src.models.starboard import StarboardSettings +from src.utils import helpers if t.TYPE_CHECKING: from miru.abc import ViewItem - from models.context import SnedSlashContext + + from src.models.context import SnedSlashContext settings = SnedPlugin("Settings") diff --git a/src/extensions/starboard.py b/src/extensions/starboard.py index d1739aa..005154e 100644 --- a/src/extensions/starboard.py +++ b/src/extensions/starboard.py @@ -4,12 +4,13 @@ import hikari import lightbulb -from etc import const -from models.bot import SnedBot -from models.context import SnedApplicationContext, SnedMessageContext, SnedSlashContext -from models.plugin import SnedPlugin -from models.starboard import StarboardEntry, StarboardSettings -from utils import helpers + +from src.etc import const +from src.models.bot import SnedBot +from src.models.context import SnedApplicationContext, SnedMessageContext, SnedSlashContext +from src.models.plugin import SnedPlugin +from src.models.starboard import StarboardEntry, StarboardSettings +from src.utils import helpers logger = logging.getLogger(__name__) diff --git a/src/extensions/tags.py b/src/extensions/tags.py index 2d242f0..890be15 100644 --- a/src/extensions/tags.py +++ b/src/extensions/tags.py @@ -5,11 +5,12 @@ import hikari import lightbulb import miru -from etc import const -from models import AuthorOnlyNavigator, SnedSlashContext, Tag -from models.bot import SnedBot -from models.plugin import SnedPlugin -from utils import helpers + +from src.etc import const +from src.models import AuthorOnlyNavigator, SnedSlashContext, Tag +from src.models.bot import SnedBot +from src.models.plugin import SnedPlugin +from src.utils import helpers logger = logging.getLogger(__name__) diff --git a/src/extensions/test.py b/src/extensions/test.py index 6b98889..247c784 100644 --- a/src/extensions/test.py +++ b/src/extensions/test.py @@ -5,9 +5,10 @@ import lightbulb import miru from miru.ext import nav -from models import SnedSlashContext -from models.bot import SnedBot -from models.plugin import SnedPlugin + +from src.models import SnedSlashContext +from src.models.bot import SnedBot +from src.models.plugin import SnedPlugin logger = logging.getLogger(__name__) diff --git a/src/extensions/troubleshooter.py b/src/extensions/troubleshooter.py index db77841..028655d 100644 --- a/src/extensions/troubleshooter.py +++ b/src/extensions/troubleshooter.py @@ -2,10 +2,11 @@ import hikari import lightbulb -from etc import const, get_perm_str -from models import SnedSlashContext -from models.bot import SnedBot -from models.plugin import SnedPlugin + +from src.etc import const, get_perm_str +from src.models import SnedSlashContext +from src.models.bot import SnedBot +from src.models.plugin import SnedPlugin logger = logging.getLogger(__name__) diff --git a/src/extensions/userlog.py b/src/extensions/userlog.py index bd83c8d..dbabeba 100644 --- a/src/extensions/userlog.py +++ b/src/extensions/userlog.py @@ -13,8 +13,9 @@ import attr import hikari import lightbulb -from etc import const, get_perm_str -from models.events import ( + +from src.etc import const, get_perm_str +from src.models.events import ( AutoModMessageFlagEvent, MassBanEvent, RoleButtonCreateEvent, @@ -24,12 +25,12 @@ WarnRemoveEvent, WarnsClearEvent, ) -from models.journal import JournalEntry, JournalEntryType -from models.plugin import SnedPlugin -from utils import helpers +from src.models.journal import JournalEntry, JournalEntryType +from src.models.plugin import SnedPlugin +from src.utils import helpers if t.TYPE_CHECKING: - from models import SnedBot + from src.models import SnedBot BOT_REASON_REGEX = re.compile(r"(?P.*)\s\((?P\d+)\):\s(?P.*)") TIMEOUT_REGEX = re.compile( diff --git a/src/models/audit_log.py b/src/models/audit_log.py index f55afda..d2708a0 100644 --- a/src/models/audit_log.py +++ b/src/models/audit_log.py @@ -5,7 +5,7 @@ import hikari if t.TYPE_CHECKING: - from models.bot import SnedBot + from src.models.bot import SnedBot import logging diff --git a/src/models/bot.py b/src/models/bot.py index 11e7111..e5328ad 100644 --- a/src/models/bot.py +++ b/src/models/bot.py @@ -11,17 +11,16 @@ import kosu import lightbulb import miru -import utils.db_backup as db_backup -from models.audit_log import AuditLogCache -from models.db import Database -from models.errors import UserBlacklistedError -from models.mod_actions import ModActions -from utils import cache, helpers, scheduler -from utils.tasks import IntervalLoop -from config import Config - -from .context import * +import src.utils.db_backup as db_backup +from src.config import Config +from src.models.audit_log import AuditLogCache +from src.models.context import * +from src.models.db import Database +from src.models.errors import UserBlacklistedError +from src.models.mod_actions import ModActions +from src.utils import cache, helpers, scheduler +from src.utils.tasks import IntervalLoop async def is_not_blacklisted(ctx: SnedContext) -> bool: diff --git a/src/models/checks.py b/src/models/checks.py index 470acca..5a3e19a 100644 --- a/src/models/checks.py +++ b/src/models/checks.py @@ -3,9 +3,10 @@ import hikari import lightbulb -from models.context import SnedApplicationContext, SnedContext -from models.errors import BotRoleHierarchyError, RoleHierarchyError -from utils import helpers + +from src.models.context import SnedApplicationContext, SnedContext +from src.models.errors import BotRoleHierarchyError, RoleHierarchyError +from src.utils import helpers def _guild_only(ctx: SnedContext) -> bool: diff --git a/src/models/context.py b/src/models/context.py index 1636ce8..a0e8001 100644 --- a/src/models/context.py +++ b/src/models/context.py @@ -5,9 +5,9 @@ import hikari import lightbulb import miru -from models.mod_actions import ModerationFlags -from .views import AuthorOnlyView +from src.models.mod_actions import ModerationFlags +from src.models.views import AuthorOnlyView __all__ = ["SnedContext", "SnedSlashContext", "SnedMessageContext", "SnedUserContext", "SnedPrefixContext"] diff --git a/src/models/db.py b/src/models/db.py index 50b303f..a196f45 100644 --- a/src/models/db.py +++ b/src/models/db.py @@ -9,11 +9,12 @@ import asyncpg import hikari -from models.errors import DatabaseStateConflictError + +from src.models.errors import DatabaseStateConflictError if t.TYPE_CHECKING: - from models.bot import SnedBot - from utils.cache import DatabaseCache + from src.models.bot import SnedBot + from src.utils.cache import DatabaseCache logger = logging.getLogger(__name__) diff --git a/src/models/db_user.py b/src/models/db_user.py index 9ac64fb..b821d3c 100644 --- a/src/models/db_user.py +++ b/src/models/db_user.py @@ -6,8 +6,9 @@ import attr import hikari -from models.db import DatabaseModel -from models.journal import JournalEntry + +from src.models.db import DatabaseModel +from src.models.journal import JournalEntry class DatabaseUserFlag(enum.Flag): diff --git a/src/models/events.py b/src/models/events.py index 90ffacd..8604b85 100644 --- a/src/models/events.py +++ b/src/models/events.py @@ -6,9 +6,9 @@ import hikari if t.TYPE_CHECKING: - from models.bot import SnedBot - from models.rolebutton import RoleButton - from models.timer import Timer + from src.models.bot import SnedBot + from src.models.rolebutton import RoleButton + from src.models.timer import Timer class SnedEvent(hikari.Event): diff --git a/src/models/journal.py b/src/models/journal.py index 2fe6f73..db27a01 100644 --- a/src/models/journal.py +++ b/src/models/journal.py @@ -6,8 +6,9 @@ import attr import hikari -from models.db import DatabaseModel -from utils import helpers + +from src.models.db import DatabaseModel +from src.utils import helpers if t.TYPE_CHECKING: import asyncpg diff --git a/src/models/mod_actions.py b/src/models/mod_actions.py index b0b1325..91e5e92 100644 --- a/src/models/mod_actions.py +++ b/src/models/mod_actions.py @@ -10,18 +10,19 @@ import hikari import lightbulb import miru -from etc import const from miru.abc import ViewItem -from models.db_user import DatabaseUser, DatabaseUserFlag -from models.errors import DMFailedError, RoleHierarchyError -from models.events import TimerCompleteEvent, WarnCreateEvent, WarnRemoveEvent, WarnsClearEvent -from models.journal import JournalEntry -from models.timer import TimerEvent -from models.views import AuthorOnlyNavigator -from utils import helpers + +from src.etc import const +from src.models.db_user import DatabaseUser, DatabaseUserFlag +from src.models.errors import DMFailedError, RoleHierarchyError +from src.models.events import TimerCompleteEvent, WarnCreateEvent, WarnRemoveEvent, WarnsClearEvent +from src.models.journal import JournalEntry +from src.models.timer import TimerEvent +from src.models.views import AuthorOnlyNavigator +from src.utils import helpers if t.TYPE_CHECKING: - from models.bot import SnedBot + from src.models.bot import SnedBot logger = logging.getLogger(__name__) diff --git a/src/models/plugin.py b/src/models/plugin.py index 66117c4..fd26c65 100644 --- a/src/models/plugin.py +++ b/src/models/plugin.py @@ -5,7 +5,7 @@ import lightbulb if t.TYPE_CHECKING: - from models.bot import SnedBot + from src.models.bot import SnedBot class SnedPlugin(lightbulb.Plugin): diff --git a/src/models/rolebutton.py b/src/models/rolebutton.py index f9a0c34..a1d8f90 100644 --- a/src/models/rolebutton.py +++ b/src/models/rolebutton.py @@ -5,8 +5,9 @@ import hikari import miru -from models.db import DatabaseModel -from models.events import RoleButtonCreateEvent, RoleButtonDeleteEvent, RoleButtonUpdateEvent + +from src.models.db import DatabaseModel +from src.models.events import RoleButtonCreateEvent, RoleButtonDeleteEvent, RoleButtonUpdateEvent class RoleButtonMode(enum.IntEnum): diff --git a/src/models/settings.py b/src/models/settings.py index 335510a..a1aec30 100644 --- a/src/models/settings.py +++ b/src/models/settings.py @@ -8,7 +8,7 @@ from miru.abc import ModalItem, ViewItem if t.TYPE_CHECKING: - from extensions.settings import SettingsView + from src.extensions.settings import SettingsView @attr.define() diff --git a/src/models/starboard.py b/src/models/starboard.py index c06fbb8..117f81a 100644 --- a/src/models/starboard.py +++ b/src/models/starboard.py @@ -5,7 +5,7 @@ import attr import hikari -from .db import DatabaseModel +from src.models.db import DatabaseModel if t.TYPE_CHECKING: import asyncpg diff --git a/src/models/tag.py b/src/models/tag.py index 86b7005..c38e10c 100644 --- a/src/models/tag.py +++ b/src/models/tag.py @@ -6,10 +6,11 @@ import attr import hikari -from models.db import DatabaseModel + +from src.models.db import DatabaseModel if t.TYPE_CHECKING: - from models.context import SnedContext + from src.models.context import SnedContext @attr.define() diff --git a/src/models/views.py b/src/models/views.py index 1b98ff8..526749e 100644 --- a/src/models/views.py +++ b/src/models/views.py @@ -1,11 +1,10 @@ -from typing import List, Optional, Union - import hikari import lightbulb import miru -from etc import const from miru.ext import nav +from src.etc import const + class StopSelect(miru.TextSelect): """A select that stops the view after interaction.""" @@ -17,7 +16,7 @@ async def callback(self, context: miru.Context) -> None: class AuthorOnlyView(miru.View): """A navigator that only works for the user who invoked it.""" - def __init__(self, lctx: lightbulb.Context, *, timeout: Optional[float] = 120, autodefer: bool = True) -> None: + def __init__(self, lctx: lightbulb.Context, *, timeout: float | None = 120, autodefer: bool = True) -> None: super().__init__(timeout=timeout, autodefer=autodefer) self.lctx = lctx @@ -39,9 +38,9 @@ class SnedNavigator(nav.NavigatorView): def __init__( self, *, - pages: List[Union[str, hikari.Embed]], - buttons: Optional[List[nav.NavButton]] = None, - timeout: Optional[float] = 120, + pages: list[str | hikari.Embed], + buttons: list[nav.NavButton] | None = None, + timeout: float | None = 120.0, autodefer: bool = True, ) -> None: buttons = buttons or [ @@ -61,9 +60,9 @@ def __init__( self, lctx: lightbulb.Context, *, - pages: List[Union[str, hikari.Embed]], - buttons: Optional[List[nav.NavButton]] = None, - timeout: Optional[float] = 300, + pages: list[str | hikari.Embed], + buttons: list[nav.NavButton] | None = None, + timeout: float | None = 300.0, autodefer: bool = True, ) -> None: self.lctx = lctx diff --git a/src/utils/cache.py b/src/utils/cache.py index 11fa86e..75ed105 100644 --- a/src/utils/cache.py +++ b/src/utils/cache.py @@ -5,12 +5,13 @@ import typing as t import hikari -from models.db import DatabaseModel + +from src.models.db import DatabaseModel logger = logging.getLogger(__name__) if t.TYPE_CHECKING: - from models import SnedBot + from src.models import SnedBot class DatabaseCache: diff --git a/src/utils/helpers.py b/src/utils/helpers.py index f623196..0f57f3f 100644 --- a/src/utils/helpers.py +++ b/src/utils/helpers.py @@ -9,14 +9,15 @@ import hikari import lightbulb import pytz -from etc import const -from models import errors -from models.db_user import DatabaseUser + +from src.etc import const +from src.models import errors +from src.models.db_user import DatabaseUser if t.TYPE_CHECKING: - from models import SnedBot - from models.context import SnedApplicationContext, SnedContext - from models.journal import JournalEntry + from src.models import SnedBot + from src.models.context import SnedApplicationContext, SnedContext + from src.models.journal import JournalEntry MESSAGE_LINK_REGEX = re.compile( r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)channels[\/][0-9]{1,}[\/][0-9]{1,}[\/][0-9]{1,}" diff --git a/src/utils/scheduler.py b/src/utils/scheduler.py index 369c920..4703aeb 100644 --- a/src/utils/scheduler.py +++ b/src/utils/scheduler.py @@ -9,15 +9,16 @@ import dateparser import hikari -from models.events import TimerCompleteEvent -from models.timer import Timer, TimerEvent -from utils.tasks import IntervalLoop + +from src.models.events import TimerCompleteEvent +from src.models.timer import Timer, TimerEvent +from src.utils.tasks import IntervalLoop logger = logging.getLogger(__name__) if t.TYPE_CHECKING: - from models.bot import SnedBot + from src.models.bot import SnedBot class ConversionMode(enum.IntEnum):