Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/SDK Version Dunder #4269

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions generate_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def write_class_attr_docs(
if module:
f.write(" def __init__(self):\r super().__init__()\r")
elif sdk_root:
f.write(" __version__ = obbff.VERSION\r\r")
f.write(" def __init__(self):\r SDKLogger()\r")

def write_class_attributes(
Expand Down
3 changes: 3 additions & 0 deletions openbb_terminal/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
controllers as ctrl,
models as model,
)
from openbb_terminal import feature_flags as obbff
from openbb_terminal.session.user import User

if User.is_guest():
Expand All @@ -39,6 +40,8 @@ class OpenBBSDK:
`whoami`: Display user info.\n
"""

__version__ = obbff.VERSION

def __init__(self):
SDKLogger()
self.login = lib.sdk_session.login
Expand Down
1 change: 1 addition & 0 deletions openbb_terminal/sdk_core/sdk_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def get_sdk_imports_text() -> str:
controllers as ctrl,
models as model,
)
from openbb_terminal import feature_flags as obbff
from openbb_terminal.session.user import User

if User.is_guest():
Expand Down
5 changes: 2 additions & 3 deletions openbb_terminal/sdk_core/trailmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ def get_definition(

definition = definition.rstrip(", ")

if location_path[0] == "root":
location_path[0] = ""

trail = ".".join([t for t in location_path if t != ""])
sdk_name = class_attr if not view else f"{class_attr}_chart"

trail = trail.lstrip("root.") # pylint: disable=E1310
sdk_path = f"{f'openbb.{trail}' if trail else 'openbb'}.{sdk_name}"

return f"{sdk_path}({definition })"
Expand Down
2 changes: 2 additions & 0 deletions tests/openbb_terminal/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
def test_openbb(mocker):
"""Test the openbb function"""
mock = mocker.patch("openbb_terminal.base_helpers.load_dotenv_and_reload_configs")
from openbb_terminal import feature_flags as obbff
from openbb_terminal.sdk import openbb

mock.assert_called_once()
assert "stocks" in dir(openbb)
assert openbb.__version__ == obbff.VERSION


# from importlib import import_module
Expand Down