diff options
author | Colin Delahunty <72827203+colin99d@users.noreply.github.com> | 2023-08-23 11:40:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 18:40:31 +0000 |
commit | 141dd68e68b6cb76abdd1a9ef5c16bf545d020a8 (patch) | |
tree | 958d514c1649cecde6b49e9b5580a086d319a1a5 | |
parent | bfd365b46b8709a8572fc26f28478aafb763cb8c (diff) |
Removed prints (#5367)
* Removed prints
* FIxed typing
* FIxed typing
* Fixed typing
* Fixed typing
* Fixed typing
* Fixed typing
* Fixed typing
* Fix
* Reverted stuff
48 files changed, 170 insertions, 150 deletions
diff --git a/custom_pre_commit/check_doc.py b/custom_pre_commit/check_doc.py index c690785e6ff..0f20540810d 100644 --- a/custom_pre_commit/check_doc.py +++ b/custom_pre_commit/check_doc.py @@ -67,12 +67,12 @@ def main(ignore_files: Optional[str], ignore_commands: Optional[str]): if not undocumented: sys.exit(0) else: - print("The following commands do not have documentation:") + print("The following commands do not have documentation:") # noqa: T201 undocumented = list(undocumented) undocumented.sort() for item in undocumented: - print(item) + print(item) # noqa: T201 sys.exit(1) diff --git a/custom_pre_commit/check_reserved_args.py b/custom_pre_commit/check_reserved_args.py index 9e9354ddb98..84f388d0eec 100644 --- a/custom_pre_commit/check_reserved_args.py +++ b/custom_pre_commit/check_reserved_args.py @@ -35,7 +35,7 @@ def process_file(file_path: str, exp: str): if long_arg is not None: long_arg = long_arg.group() if long_arg not in ("HistoryManager.hist_file", RESERVED_ARGS[short_arg]): - print( + print( # noqa: T201 f"{file_path}: " f"'-{short_arg}' argument expected '{RESERVED_ARGS[short_arg]}'" f" but assigned to '{long_arg}'" diff --git a/openbb_terminal/account/account_view.py b/openbb_terminal/account/account_view.py index 5dcbff376bf..fb40d32fbef 100644 --- a/openbb_terminal/account/account_view.py +++ b/openbb_terminal/account/account_view.py @@ -57,8 +57,7 @@ def display_personal_routines(df: pd.DataFrame, page: int, pages: int): show_index=True, index_name="#", ) - except Exception as exc: - print(exc) + except Exception: console.print("Failed to display personal routines.") @@ -72,7 +71,6 @@ def display_default_routines(df: pd.DataFrame): """ try: df = df.rename(columns={"date_updated": "updated_date"}) - print(df) df = clean_df(df) print_rich_table( df=df, diff --git a/openbb_terminal/common/behavioural_analysis/finnhub_view.py b/openbb_terminal/common/behavioural_analysis/finnhub_view.py index fbf69c2765b..b2a40729157 100644 --- a/openbb_terminal/common/behavioural_analysis/finnhub_view.py +++ b/openbb_terminal/common/behavioural_analysis/finnhub_view.py @@ -32,7 +32,6 @@ def display_sentiment_stats( Format to export data """ d_stats = finnhub_model.get_sentiment_stats(ticker) - print(d_stats) if d_stats.empty: return diff --git a/openbb_terminal/common/technical_analysis/volatility_model.py b/openbb_terminal/common/technical_analysis/volatility_model.py index b786799727a..39e6ea9017c 100644 --- a/openbb_terminal/common/technical_analysis/volatility_model.py +++ b/openbb_terminal/common/technical_analysis/volatility_model.py @@ -10,6 +10,7 @@ import pandas_ta as ta from openbb_terminal.common.technical_analysis import ta_helpers from openbb_terminal.decorators import log_start_end +from openbb_terminal.rich_config import console logger = logging.getLogger(__name__) @@ -216,11 +217,11 @@ def standard_deviation( """ if window < 2: - print("Error: Window must be at least 2, defaulting to 30.") + console.print("Error: Window must be at least 2, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -273,11 +274,11 @@ def parkinson( """ if window < 1: - print("Error: Window must be at least 1, defaulting to 30.") + console.print("Error: Window must be at least 1, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -334,11 +335,11 @@ def garman_klass( """ if window < 1: - print("Error: Window must be at least 1, defaulting to 30.") + console.print("Error: Window must be at least 1, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -395,11 +396,11 @@ def hodges_tompkins( """ if window < 2: - print("Error: Window must be at least 2, defaulting to 30.") + console.print("Error: Window must be at least 2, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -460,11 +461,11 @@ def rogers_satchell( """ if window < 1: - print("Error: Window must be at least 1, defaulting to 30.") + console.print("Error: Window must be at least 1, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -521,11 +522,11 @@ def yang_zhang( """ if window < 2: - print("Error: Window must be at least 2, defaulting to 30.") + console.print("Error: Window must be at least 2, defaulting to 30.") window = 30 if trading_periods and is_crypto: - print("is_crypto is overridden by trading_periods.") + console.print("is_crypto is overridden by trading_periods.") if not trading_periods: trading_periods = 365 if is_crypto else 252 @@ -624,7 +625,7 @@ def cones( lower_q, upper_q = upper_q, lower_q if (lower_q >= 1) or (upper_q >= 1): - print("Error: lower_q and upper_q must be between 0 and 1") + console.print("Error: lower_q and upper_q must be between 0 and 1") cones_df = pd.DataFrame() return cones_df @@ -644,7 +645,9 @@ def cones( for window in windows: # Looping to build a dataframe with realized volatility over each window. if model not in VOLATILITY_MODELS: - print("Model not available. Available models: ", VOLATILITY_MODELS) + console.print( + "Model not available. Available models: ", VOLATILITY_MODELS + ) elif model == "STD": estimator = standard_deviation( window=window, data=data, is_crypto=is_crypto diff --git a/openbb_terminal/core/models/sources_model.py b/openbb_terminal/core/models/sources_model.py index ad8d885bff7..384aaf4a765 100644 --- a/openbb_terminal/core/models/sources_model.py +++ b/openbb_terminal/core/models/sources_model.py @@ -22,7 +22,7 @@ def read_default_sources() -> Dict: with open(DATA_SOURCES_DEFAULT_FILE) as file: return flatten(json.load(file)) except Exception as e: - print( + print( # noqa: T201 f"\nFailed to read data sources file: " f"{DATA_SOURCES_DEFAULT_FILE}\n{e}\n" ) diff --git a/openbb_terminal/core/plots/backend.py b/openbb_terminal/core/plots/backend.py index 2a8e02c5b4d..235af4d651f 100644 --- a/openbb_terminal/core/plots/backend.py +++ b/openbb_terminal/core/plots/backend.py @@ -23,7 +23,7 @@ from openbb_terminal.core.session.constants import BackendEnvironment try: from pywry import PyWry except ImportError as e: - print(f"\033[91m{e}\033[0m") + print(f"\033[91m{e}\033[0m") # noqa: T201 # pylint: disable=C0412 from openbb_terminal.core.plots.no_import import DummyBackend @@ -54,7 +54,7 @@ else: JUPYTER_NOTEBOOK = True PLOTS_CORE_PATH = Path(__file__).parent.resolve() -PLOTLYJS_PATH = PLOTS_CORE_PATH / "assets" / "plotly-2.24.2.min.js" +PLOTLYJS_PATH: Path = PLOTS_CORE_PATH / "assets" / "plotly-2.24.2.min.js" BACKEND = None @@ -496,7 +496,7 @@ async def download_plotly_js(): file.unlink(missing_ok=True) except Exception as err: # pylint: disable=W0703 - print(f"Error downloading plotly.js: {err}") + console.print(f"Error downloading plotly.js: {err}") def plots_backend() -> Backend: diff --git a/openbb_terminal/core/plots/plotly_helper.py b/openbb_terminal/core/plots/plotly_helper.py index 2546a75f6b3..19ca0c730ac 100644 --- a/openbb_terminal/core/plots/plotly_helper.py +++ b/openbb_terminal/core/plots/plotly_helper.py @@ -29,9 +29,7 @@ from scipy import stats from openbb_terminal import config_terminal from openbb_terminal.base_helpers import console, strtobool -from openbb_terminal.core.config.paths import ( - STYLES_DIRECTORY_REPO, -) +from openbb_terminal.core.config.paths import STYLES_DIRECTORY_REPO from openbb_terminal.core.plots.backend import PLOTLYJS_PATH, plots_backend from openbb_terminal.core.plots.config.openbb_styles import ( PLT_COLORWAY, @@ -59,7 +57,7 @@ class TerminalStyle: """ STYLES_REPO = STYLES_DIRECTORY_REPO - USER_STYLES_DIRECTORY = get_current_user().preferences.USER_STYLES_DIRECTORY + USER_STYLES_DIRECTORY: Path = get_current_user().preferences.USER_STYLES_DIRECTORY plt_styles_available: Dict[str, Path] = {} plt_style: str = "dark" diff --git a/openbb_terminal/core/scripts/sdk_audit.py b/openbb_terminal/core/scripts/sdk_audit.py index ee65cbb6185..b67f427a487 100644 --- a/openbb_terminal/core/scripts/sdk_audit.py +++ b/openbb_terminal/core/scripts/sdk_audit.py @@ -8,6 +8,7 @@ from typing import Callable, List, Tuple import pandas as pd from openbb_terminal.core.config.paths import MAP_PATH +from openbb_terminal.rich_config import console try: import darts # pylint: disable=W0611 # noqa: F401 @@ -84,8 +85,10 @@ def get_sdk(file_path: Path = MAP_PATH) -> pd.DataFrame: df = pd.read_csv(base_path / file_path) df_dups = len(df["trail"]) - len(df["trail"].drop_duplicates()) if df_dups > 0: - print(f"Number of duplicate sdk paths: {df_dups}") - print("This indicates that the same SDK trail is being used multiple times\n") + console.print(f"Number of duplicate sdk paths: {df_dups}") + console.print( + "This indicates that the same SDK trail is being used multiple times\n" + ) views = list(df[["view", "trail"]].itertuples(index=False, name=None)) models = list(df[["model", "trail"]].itertuples(index=False, name=None)) # Add in whether it is a view or a model in pandas @@ -146,8 +149,8 @@ def functions_df() -> pd.DataFrame: func_df["docstring"] = [x[1] for x in all_formatted] func_dups = len(func_df["name"]) - len(func_df["name"].drop_duplicates()) if func_dups > 0: - print(f"Number of duplicate functions found: {func_dups}") - print( + console.print(f"Number of duplicate functions found: {func_dups}") + console.print( "This may indicate that functions are defined several times in the terminal.\n" ) func_df = func_df.set_index("name") @@ -159,7 +162,7 @@ def save_df(data: pd.DataFrame) -> None: time_str = (str(timestamp)).replace(".", "") output_path = f"{time_str}_sdk_audit.csv" data.to_csv(output_path) - print(f"File saved to {output_path}") + console.print(f"File saved to {output_path}") def get_nonconforming_functions(data: pd.DataFrame) -> pd.DataFrame: @@ -192,7 +195,7 @@ def get_nonconforming_functions(data: pd.DataFrame) -> pd.DataFrame: def main(): - print( + console.print( "This tool checks all functions in a file with a name including 'view' or 'model'against\n" "all functions in the sdk, which is gathered from 'trail_map.csv'. If the generated csv\n" "has an entry for 'trail' that means it is in the SDK, and if it has an entry for\n" @@ -209,15 +212,17 @@ def main(): # Get further stats on bad data no_doc_count = len(final_df[final_df["docstring"].isnull()].index) if no_doc_count > 0: - print(f"The number of rows with blank docstrings is: {no_doc_count}") - print( + console.print(f"The number of rows with blank docstrings is: {no_doc_count}") + console.print( "This indicates a matching function does not exist, is not in a 'model' or 'view'\n" "file, or that the trailmap does not import it from the place it is defined.\n" ) dup_name_count = len(final_df[final_df.duplicated(keep=False)].index) if dup_name_count > 0: - print(f"The number of duplicate functions after merge is: {dup_name_count}") - print( + console.print( + f"The number of duplicate functions after merge is: {dup_name_count}" + ) + console.print( "This most likely indicates that the same function is being used at " "different SDK endpoints.\n" ) diff --git a/openbb_terminal/core/session/sources_handler.py b/openbb_terminal/core/session/sources_handler.py index 83901db44c2..ac1dd91b4f1 100644 --- a/openbb_terminal/core/session/sources_handler.py +++ b/openbb_terminal/core/session/sources_handler.py @@ -26,8 +26,8 @@ def read_sources(path: Path) -> Dict: return flatten(json.load(file)) return {} except Exception as e: - print(f"\nFailed to read data sources file: {path}\n{e}\n") - print("Falling back to OpenBB default sources.") + print(f"\nFailed to read data sources file: {path}\n{e}\n") # noqa: T201 + print("Falling back to OpenBB default sources.") # noqa: T201 return {} @@ -45,7 +45,7 @@ def write_sources(sources: Dict, path: Path): with open(path, "w") as f: json.dump(extend(sources), f, indent=4) except Exception as e: - print(f"\nFailed to write data sources file: {path}\n{e}\n") + print(f"\nFailed to write data sources file: {path}\n{e}\n") # noqa: T201 def merge_sources(incoming: Dict, allowed: Dict): diff --git a/openbb_terminal/core/session/utils.py b/openbb_terminal/core/session/utils.py index 45ab3e509ee..5d20941c541 100644 --- a/openbb_terminal/core/session/utils.py +++ b/openbb_terminal/core/session/utils.py @@ -27,7 +27,7 @@ def load_dict_to_model(dictionary: dict, model: Type[T]) -> T: try: return m |