Skip to content

Commit

Permalink
filter empty credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoaquim committed Sep 15, 2023
1 parent 03f18f5 commit 3cf7751
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions openbb_terminal/core/models/credentials_model.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions openbb_terminal/core/session/local_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3cf7751

Please sign in to comment.