From 8b22f1c63a8dbf841fef464e7ee5176d779b863c Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 7 Jul 2026 21:33:49 +0000 Subject: [PATCH] refactor: Lazy load celery_app in __getattr__ to improve module attribute access and reduce initial import overhead. --- dispatcharr/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dispatcharr/__init__.py b/dispatcharr/__init__.py index 178024f2..2f688176 100644 --- a/dispatcharr/__init__.py +++ b/dispatcharr/__init__.py @@ -1,6 +1,11 @@ # dispatcharr/__init__.py -# For Celery: -from .celery import app as celery_app - __all__ = ("celery_app",) + + +def __getattr__(name: str): + if name == "celery_app": + from .celery import app as celery_app + + return celery_app + raise AttributeError(f"module {__name__!r} has no attribute {name!r}")