From 80163ce994487b7a5471ffa38261960e72e8fd51 Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Sat, 11 Oct 2025 02:06:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Make=20settings=20module=20avail?= =?UTF-8?q?able,=20first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ohmyapi/core/runtime.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ohmyapi/core/runtime.py b/src/ohmyapi/core/runtime.py index e3d700e..8fedc3c 100644 --- a/src/ohmyapi/core/runtime.py +++ b/src/ohmyapi/core/runtime.py @@ -40,6 +40,14 @@ class Project: if str(self.project_path) not in sys.path: sys.path.insert(0, str(self.project_path)) + # Load settings.py + try: + self.settings = importlib.import_module("settings") + except Exception as e: + raise RuntimeError( + f"Failed to import project settings from {self.project_path}" + ) from e + # Alias builtin apps as ohmyapi_. # We need this, because Tortoise app-names may not include dots `.`. spec = importlib.util.find_spec("ohmyapi.builtin") @@ -57,14 +65,6 @@ class Project: except ModuleNotFoundError: pass - # Load settings.py - try: - self.settings = importlib.import_module("settings") - except Exception as e: - raise RuntimeError( - f"Failed to import project settings from {self.project_path}" - ) from e - # Load installed apps for app_name in getattr(self.settings, "INSTALLED_APPS", []): self._apps[app_name] = App(self, name=app_name)