From 96d21f71fdc77ba3870426365d063cab4dc225d5 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Mon, 10 Apr 2023 14:09:14 +0530 Subject: [PATCH] Added fix (#4710) * Added fix * Fixed `load`, `find`, `price` and refactored code * Modified line 1304 in parent_classes.py --------- Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com> Co-authored-by: Henrique Joaquim --- .../cryptocurrency/crypto_controller.py | 27 +++++++------------ openbb_terminal/parent_classes.py | 2 +- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/openbb_terminal/cryptocurrency/crypto_controller.py b/openbb_terminal/cryptocurrency/crypto_controller.py index 451c40f0249d..c97a4cd11b5c 100644 --- a/openbb_terminal/cryptocurrency/crypto_controller.py +++ b/openbb_terminal/cryptocurrency/crypto_controller.py @@ -165,7 +165,7 @@ def call_prt(self, other_args): help="Coin to compare with", dest="vs", type=str, - # required="-h" not in other_args, + required="-h" not in other_args and "--help" not in other_args, default=None, ) parser.add_argument( @@ -187,11 +187,9 @@ def call_prt(self, other_args): if other_args and "-" not in other_args[0][0]: other_args.insert(0, "--vs") - ns_parser = self.parse_known_args_and_warn( + if ns_parser := self.parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED - ) - - if ns_parser: + ): if self.symbol: num_args = 0 for arg in vars(ns_parser): @@ -240,7 +238,7 @@ def call_price(self, other_args): parser.add_argument( "-s", "--symbol", - required="-h" not in other_args, + required="-h" not in other_args and "--help" not in other_args, type=str, dest="symbol", help="Symbol of coin to load data for, ~100 symbols are available", @@ -250,9 +248,7 @@ def call_price(self, other_args): if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-s") - ns_parser = self.parse_known_args_and_warn(parser, other_args) - - if ns_parser: + if ns_parser := self.parse_known_args_and_warn(parser, other_args): upper_symbol = ns_parser.symbol.upper() if "-USD" not in ns_parser.symbol: upper_symbol += "-USD" @@ -283,10 +279,9 @@ def call_candle(self, other_args): dest="logy", ) - ns_parser = self.parse_known_args_and_warn( + if ns_parser := self.parse_known_args_and_warn( parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES - ) - if ns_parser: + ): if not self.symbol: console.print("No coin loaded. First use `load {symbol}`\n") return @@ -385,11 +380,9 @@ def call_headlines(self, other_args): ) if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-c") - ns_parser = self.parse_known_args_and_warn( + if ns_parser := self.parse_known_args_and_warn( parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES - ) - - if ns_parser: + ): finbrain_crypto_view.display_crypto_sentiment_analysis( symbol=ns_parser.coin, export=ns_parser.export ) @@ -474,7 +467,7 @@ def call_find(self, other_args): "--coin", help="Symbol Name or Id of Coin", dest="coin", - required="-h" not in other_args, + required="-h" not in other_args and "--help" not in other_args, type=str, ) parser.add_argument( diff --git a/openbb_terminal/parent_classes.py b/openbb_terminal/parent_classes.py index 4076cf1c1724..26c833791dc9 100644 --- a/openbb_terminal/parent_classes.py +++ b/openbb_terminal/parent_classes.py @@ -1301,7 +1301,7 @@ def call_load(self, other_args): help="Coin to get. Must be coin symbol (e.g., btc, eth)", dest="coin", type=str, - required="-h" not in other_args, + required="-h" not in other_args and "--help" not in other_args, ) parser.add_argument(