fix(notifications): break db <-> notifications.persistence circular import

When app.notifications is the import entry point (e.g. Celery loading
app.notifications.service before any ORM code), app.db re-entered the
half-initialized app.notifications.persistence at its model-registration import
and failed with "cannot import name 'Notification' ... partially initialized".

Import app.db at the top of app/notifications/__init__.py so db fully initializes
(including its own Notification registration) before we re-import from
.persistence. Pre-existing issue (reproduces on the base commit); surfaced by the
celery worker startup.
This commit is contained in:
CREDO23 2026-06-05 16:52:14 +02:00
parent 88fe213176
commit 620c378254

View file

@ -6,6 +6,10 @@ the router in :mod:`app.notifications.api` exposes the inbox endpoints.
from __future__ import annotations from __future__ import annotations
# Initialize app.db first to avoid a partial-init circular import when this
# package is the entry point (e.g. Celery loading it before any ORM code).
import app.db # noqa: F401
from app.notifications.persistence import Notification from app.notifications.persistence import Notification
from app.notifications.service import NotificationService from app.notifications.service import NotificationService