From 0d270c9cfb3d00dcf8bc20743eadc74717374b55 Mon Sep 17 00:00:00 2001 From: Campbell Alden Date: Thu, 3 Sep 2026 22:57:55 +0900 Subject: [PATCH] Setup exports in the infra __init__.py This helps avoid issues where model classes are not evaluated. If the models are not properly imported then Sqlalchemy can explode during database initialization since the mapped columns have not yet been registered. Later, having the models all imported into __init__.py will help with setting up a test db since it will ensure that the registrations for all models is happening as the classes are evaluated during the imports in the package init file. --- src/infra/__init__.py | 27 +++++++++++++++++++++++++++ src/main.py | 3 +-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/infra/__init__.py b/src/infra/__init__.py index e69de29..8851384 100644 --- a/src/infra/__init__.py +++ b/src/infra/__init__.py @@ -0,0 +1,27 @@ +from .db import Base, CRUD, CRUDRepo, UpdateMissingEntryError, get_database +from .users import UserModel, UserRepoImpl +from .publication import ( + PublicationEntryModel, + PublicationSequenceModel, + PublicationOrderModel, + PublicationModel, + PublicationRepoImpl, +) +from .subscription import SubscriptionModel, SubscriptionRepoImpl + +__all__ = [ + 'Base', + 'CRUD', + 'CRUDRepo', + 'UpdateMissingEntryError', + 'get_database', + 'UserModel', + 'UserRepoImpl', + 'PublicationEntryModel', + 'PublicationSequenceModel', + 'PublicationOrderModel', + 'PublicationModel', + 'PublicationRepoImpl', + 'SubscriptionModel', + 'SubscriptionRepoImpl', +] diff --git a/src/main.py b/src/main.py index aca6e66..f9fb8fd 100644 --- a/src/main.py +++ b/src/main.py @@ -6,8 +6,7 @@ from src.services.email import EmailService, get_email_service from src.services.auth import AuthService from src.services.users.service import UserService from dataclasses import dataclass -from src.infra.db import get_database -from src.infra.users import UserRepoImpl +from src.infra import get_database, UserRepoImpl from waitress import serve from flask import Flask import argparse