diff --git a/openbb_terminal/core/models/credentials_model.py b/openbb_terminal/core/models/credentials_model.py index 50e5801bbb18..a72d1a2ba6c6 100644 --- a/openbb_terminal/core/models/credentials_model.py +++ b/openbb_terminal/core/models/credentials_model.py @@ -1,6 +1,6 @@ import json from dataclasses import make_dataclass -from typing import Optional +from typing import Any, List, Tuple from pydantic.dataclasses import dataclass as pydanticdataclass @@ -14,12 +14,13 @@ LOCAL_CREDENTIALS = json.load(f) +fields: List[Tuple[str, type, Any]] = [ + (k, str, "REPLACE_ME") for k in list(HUB_CREDENTIALS) + list(LOCAL_CREDENTIALS) +] + dc = make_dataclass( cls_name="CredentialsModel", - fields=[ - (k, Optional[str], "REPLACE_ME") - for k in list(HUB_CREDENTIALS) + list(LOCAL_CREDENTIALS) - ], + fields=fields, bases=(BaseModel,), ) dc.__repr__ = dc.__base__.__repr__ # type: ignore diff --git a/openbb_terminal/core/session/local_model.py b/openbb_terminal/core/session/local_model.py index 64d9e868b366..8836950649f3 100644 --- a/openbb_terminal/core/session/local_model.py +++ b/openbb_terminal/core/session/local_model.py @@ -128,6 +128,7 @@ def set_credentials_from_hub(configs: dict): """ if configs: credentials = configs.get("features_keys", {}) or {} + credentials = {k: v for k, v in credentials.items() if v} for k, v in credentials.items(): set_credential(k, v)