diff --git a/generate_sdk.py b/generate_sdk.py index 14d315de0cf..ec57836ce4f 100644 --- a/generate_sdk.py +++ b/generate_sdk.py @@ -240,7 +240,7 @@ class BuildCategoryModelClasses: if module: f.write(" def __init__(self):\r super().__init__()\r") elif sdk_root: - f.write(" __version__ = obbff.VERSION\r\r") + f.write(" __version__ = cfg.VERSION\r\r") f.write(" def __init__(self):\r SDKLogger()\r") def write_class_attributes( diff --git a/openbb_terminal/config_terminal.py b/openbb_terminal/config_terminal.py index ee34f9470ff..17e698acd5c 100644 --- a/openbb_terminal/config_terminal.py +++ b/openbb_terminal/config_terminal.py @@ -81,7 +81,7 @@ try: else: raise Exception("Using git") except Exception: - version = "2.4.1" + version = "2.5.1" VERSION = str(os.getenv("OPENBB_VERSION", version)) # # Select the terminal translation language diff --git a/openbb_terminal/feature_flags.py b/openbb_terminal/feature_flags.py deleted file mode 100644 index 216f229643b..00000000000 --- a/openbb_terminal/feature_flags.py +++ /dev/null @@ -1,39 +0,0 @@ -# IMPORTATION STANDARD -import os -import os.path - -# IMPORTATION THIRDPARTY -import i18n - -# IMPORTATION INTERNAL -from openbb_terminal.core.config.paths import ( - MISCELLANEOUS_DIRECTORY, -) -from openbb_terminal.core.session.current_user import get_current_user - -# pylint: disable=no-member,c-extension-no-member - -try: - __import__("git") -except ImportError: - WITH_GIT = False -else: - WITH_GIT = True - - -try: - if not WITH_GIT: - import pkg_resources - - version = pkg_resources.get_distribution("OpenBB").version - else: - raise Exception("Using git") -except Exception: - version = "2.5.1" -VERSION = str(os.getenv("OPENBB_VERSION", version)) - -# # Select the terminal translation language -i18n_dict_location = MISCELLANEOUS_DIRECTORY / "i18n" -i18n.load_path.append(i18n_dict_location) -i18n.set("locale", get_current_user().preferences.USE_LANGUAGE) -i18n.set("filename_format", "{locale}.{format}") diff --git a/openbb_terminal/settings_controller.py b/openbb_terminal/settings_controller.py index 6e1b9949d2b..9c439d2278c 100644 --- a/openbb_terminal/settings_controller.py +++ b/openbb_terminal/settings_controller.py @@ -12,8 +12,9 @@ from typing import List, Optional # IMPORTATION THIRDPARTY import pytz +from openbb_terminal.config_terminal import i18n_dict_location + # IMPORTATION INTERNAL -from openbb_terminal import feature_flags as obbff from openbb_terminal.core.config.paths import ( SETTINGS_ENV_FILE, USER_DATA_SOURCES_DEFAULT_FILE, @@ -65,7 +66,7 @@ class SettingsController(BaseController): languages_available = [ lang.strip(".yml") - for lang in os.listdir(obbff.i18n_dict_location) + for lang in os.listdir(i18n_dict_location) if lang.endswith(".yml") ] diff --git a/openbb_terminal/terminal_helper.py b/openbb_terminal/terminal_helper.py index a999a49e443..dcd14fedb7b 100644 --- a/openbb_terminal/terminal_helper.py +++ b/openbb_terminal/terminal_helper.py @@ -17,10 +17,9 @@ import matplotlib.pyplot as plt from packaging import version from openbb_terminal import ( - feature_flags as obbff, thought_of_the_day as thought, ) -from openbb_terminal.config_terminal import LOGGING_COMMIT_HASH +from openbb_terminal.config_terminal import LOGGING_COMMIT_HASH, VERSION # IMPORTATION INTERNAL from openbb_terminal.core.config.paths import SETTINGS_ENV_FILE @@ -266,7 +265,7 @@ def bootup(): def check_for_updates() -> None: """Check if the latest version is running. - Checks github for the latest release version and compares it to obbff.VERSION. + Checks github for the latest release version and compares it to cfg.VERSION. """ # The commit has was commented out because the terminal was crashing due to git import for multiple users # ({str(git.Repo('.').head.commit)[:7]}) @@ -280,7 +279,7 @@ def check_for_updates() -> None: if r is not None and r.status_code == 200: latest_tag_name = r.json()["tag_name"] latest_version = version.parse(latest_tag_name) - current_version = version.parse(obbff.VERSION) + current_version = version.parse(VERSION) if check_valid_versions(latest_version, current_version): if current_version == latest_version: @@ -328,7 +327,7 @@ def welcome_message(): Prints first welcome message, help and a notification if updates are available. """ - console.print(f"\nWelcome to OpenBB Terminal v{obbff.VERSION}") + console.print(f"\nWelcome to OpenBB Terminal v{VERSION}") if get_current_user().preferences.ENABLE_THOUGHTS_DAY: console.print("---------------------------------") diff --git a/tests/openbb_terminal/account/test_account_model.py b/tests/openbb_terminal/account/test_account_model.py index 24bd4085f7b..8ba58d13a4f 100644 --- a/tests/openbb_terminal/account/test_account_model.py +++ b/tests/openbb_terminal/account/test_account_model.py @@ -6,7 +6,6 @@ from unittest.mock import patch # IMPORTATION THIRDPARTY from openbb_terminal import ( config_terminal as cfg, - feature_flags as obbff, ) from openbb_terminal.account import account_model from openbb_terminal.core.config import paths @@ -151,7 +150,6 @@ def test_get_diff_settings_empty_settings(): def test_get_diff_settings_no_diff(): - obbff.value = 1 cfg.value = 1 paths.value = 1 diff = account_model.get_diff_settings({"value": 1}) diff --git a/tests/openbb_terminal/forecast/test_forecast_controller.py b/tests/openbb_terminal/forecast/test_forecast_controller.py index 69167e15818..b5282f8b3a0 100644 --- a/tests/openbb_terminal/forecast/test_forecast_controller.py +++ b/tests/openbb_terminal/forecast/test_forecast_controller.py @@ -4,6 +4,8 @@ from typing import List import pandas as pd import pytest +from openbb_terminal.core.models.preferences_model import PreferencesModel +from openbb_terminal.core.session.current_user import copy_user from openbb_terminal.custom_prompt_toolkit import NestedCompleter try: @@ -39,14 +41,24 @@ def test_check_greater_than_one_invalid(): def test_forecast_controller(mocker): mocker.patch(base + "session", True) - mocker.patch(base + "obbff.USE_PROMPT_TOOLKIT", True) + preferences = PreferencesModel(USE_PROMPT_TOOLKIT=True) + mock_current_user = copy_user(preferences=preferences) + mocker.patch( + target="openbb_terminal.core.session.current_user.__current_user", + new=mock_current_user, + ) cont = fc.ForecastController(data=df, ticker="TSLA") assert isinstance(cont.files, List) def test_fc_update_runtime_choices(mocker): mocker.patch(base + "session", True) - mocker.patch(base + "obbff.USE_PROMPT_TOOLKIT", True) + preferences = PreferencesModel(USE_PROMPT_TOOLKIT=True) + mock_current_user = copy_user(preferences=preferences) + mocker.patch( + target="openbb_terminal.core.session.current_user.__current_user", + new=mock_current_user, + ) cont = fc.ForecastController() cont.datasets = {"stonks": df} cont.update_runtime_choices() diff --git a/tests/openbb_terminal/session/test_user.py b/tests/openbb_terminal/session/test_user.py index 3da410608a0..b01000f78e9 100644 --- a/tests/openbb_terminal/session/test_user.py +++ b/tests/openbb_terminal/session/test_user.py @@ -31,13 +31,6 @@ def fixture_test_user(): return test_user -class obbff: - """Mock obbff.""" - - USE_FLAIR = ":openbb" - SYNC_ENABLED = True - - def test_load_user_info(test_user): """Test load user info.""" assert test_user.profile.token == "test_token" diff --git a/tests/openbb_terminal/test_terminal_helper.py b/tests/openbb_terminal/test_terminal_helper.py index c58e2c23592..60d1df08857 100644 --- a/tests/openbb_terminal/test_terminal_helper.py +++ b/tests/openbb_terminal/test_terminal_helper.py @@ -85,7 +85,7 @@ def test_check_for_updates(mocker, last_release, current_release): # MOCK FF VERSION mocker.patch( - target="openbb_terminal.feature_flags.VERSION", + target="openbb_terminal.config_terminal.VERSION", new=current_release, )