From 53b6471ea9f3a491fc6ae9d39075a32da838be89 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:02:53 -0700 Subject: [PATCH] [BugFix] Improve Warning For Invalid Defaults Key In `user_settings.json` (#6651) * improve warning for invalid defaults key in user_settings.json * didn't add to the commit --- .../core/openbb_core/app/model/defaults.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/defaults.py b/openbb_platform/core/openbb_core/app/model/defaults.py index a6eb632ac8e..8dda33d222d 100644 --- a/openbb_platform/core/openbb_core/app/model/defaults.py +++ b/openbb_platform/core/openbb_core/app/model/defaults.py @@ -30,11 +30,16 @@ class Defaults(BaseModel): """Validate model (before).""" key = "commands" if "routes" in values: - warn( - message="'routes' is deprecated. Use 'commands' instead.", - category=OpenBBWarning, - ) - key = "routes" + if not values.get("routes"): + del values["routes"] + show_warnings = values.get("preferences", {}).get("show_warnings") + if show_warnings is False or show_warnings in ["False", "false"]: + warn( + message="The 'routes' key is deprecated within 'defaults' of 'user_settings.json'." + + " Suppress this warning by updating the key to 'commands'.", + category=OpenBBWarning, + ) + key = "routes" new_values: Dict[str, Dict[str, Optional[List[str]]]] = {"commands": {}} for k, v in values.get(key, {}).items():