From e3b816d85e402c363cc11610ae20760cdab698ab Mon Sep 17 00:00:00 2001
From: Kiara Grouwstra <kiara@procolix.eu>
Date: Wed, 19 Mar 2025 10:22:52 +0100
Subject: [PATCH] revert change on USER_SETTINGS_FILE, fixing dev shell

---
 panel/src/panel/settings.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/panel/src/panel/settings.py b/panel/src/panel/settings.py
index 4ca359c6..90f6fe27 100644
--- a/panel/src/panel/settings.py
+++ b/panel/src/panel/settings.py
@@ -176,14 +176,15 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 # TODO(@fricklerhandwerk):
 #     we may want to do this with a flat environment instead, and get all values from `os.environ.get()`.
 #     this would make it more obvious which moving parts there are, if that environment is specified for development/staging/production in a visible place.
-user_settings_file = env["USER_SETTINGS_FILE"]
-spec = importlib.util.spec_from_file_location("user_settings", user_settings_file)
-if spec is None or spec.loader is None:
-    raise RuntimeError("User settings specification failed!")
-module = importlib.util.module_from_spec(spec)
-spec.loader.exec_module(module)
-sys.modules["user_settings"] = module
-from user_settings import *  # noqa: F403 # pyright: ignore [reportMissingImports]
+user_settings_file = env.get("USER_SETTINGS_FILE", None)
+if user_settings_file is not None:
+    spec = importlib.util.spec_from_file_location("user_settings", user_settings_file)
+    if spec is None or spec.loader is None:
+        raise RuntimeError("User settings specification failed!")
+    module = importlib.util.module_from_spec(spec)
+    spec.loader.exec_module(module)
+    sys.modules["user_settings"] = module
+    from user_settings import *  # noqa: F403 # pyright: ignore [reportMissingImports]
 
 # non-Django application settings