diff --git a/openbb_terminal/cryptocurrency/crypto_api.py b/openbb_terminal/cryptocurrency/crypto_api.py index 450e0bace07..b802d02b254 100644 --- a/openbb_terminal/cryptocurrency/crypto_api.py +++ b/openbb_terminal/cryptocurrency/crypto_api.py @@ -26,7 +26,6 @@ from .due_diligence.finbrain_crypto_view import ( try: from .prediction_techniques import pred_api as pred except Exception: - # print("Prediction API is not available.") pass # Models diff --git a/openbb_terminal/cryptocurrency/due_diligence/cryptopanic_view.py b/openbb_terminal/cryptocurrency/due_diligence/cryptopanic_view.py index 89d0ac8d9a5..cf6d66219e3 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/cryptopanic_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/cryptopanic_view.py @@ -27,7 +27,8 @@ def display_news( descend: bool = False, export: str = "", ) -> None: - """Display recent posts from CryptoPanic news aggregator platform. [Source: https://cryptopanic.com/] + """Display recent posts from CryptoPanic news aggregator platform. + [Source: https://cryptopanic.com/] Parameters ---------- @@ -38,8 +39,8 @@ def display_news( filter_: Optional[str] Filter by kind of news. One from list: rising|hot|bullish|bearish|important|saved|lol region: str - Filter news by regions. Available regions are: en (English), de (Deutsch), nl (Dutch), es (Español), - fr (Français), it (Italiano), pt (Português), ru (Русский) + Filter news by regions. Available regions are: en (English), de (Deutsch), nl (Dutch), + es (Español), fr (Français), it (Italiano), pt (Português), ru (Русский) descend: bool Sort in descending order. export : str diff --git a/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py b/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py index 06b6d9cc0ce..c749b6e1b99 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py +++ b/openbb_terminal/cryptocurrency/due_diligence/santiment_view.py @@ -1,8 +1,8 @@ import logging import os from typing import List, Optional - from datetime import datetime, timedelta + from matplotlib import pyplot as plt from openbb_terminal.config_terminal import theme @@ -18,6 +18,7 @@ from openbb_terminal.helper_funcs import ( is_valid_axes_count, ) + logger = logging.getLogger(__name__) diff --git a/openbb_terminal/menu.py b/openbb_terminal/menu.py index 3c5688eb93b..b7a6a30594b 100644 --- a/openbb_terminal/menu.py +++ b/openbb_terminal/menu.py @@ -1,3 +1,4 @@ +from typing import Optional import logging import os @@ -9,6 +10,15 @@ from prompt_toolkit.history import FileHistory logger = logging.getLogger(__name__) +# pylint: disable=W0104 +def is_jupyter() -> bool: + try: + __IPYTHON__ # type: ignore + return True + except NameError: + return False + + def inputhook(inputhook_context): while not inputhook_context.input_is_ready(): try: @@ -22,12 +32,18 @@ def inputhook(inputhook_context): history_file = os.path.join(os.path.expanduser("~"), ".openbb_terminal.his") try: - session = PromptSession(history=FileHistory(history_file)) # type: ignore - set_eventloop_with_inputhook(inputhook) + if not is_jupyter(): + session: Optional[PromptSession] = PromptSession( + history=FileHistory(history_file) + ) + set_eventloop_with_inputhook(inputhook) + else: + session = None # pylint: disable=unused-variable except Exception as e: # noqa: F841 logger.exception("%s", type(e).__name__) print( - "WARNING: Prompt toolkit is turned on but did not initialize successfully. Falling back to input()..." + "WARNING: Prompt toolkit is turned on but did not initialize successfully." + " Falling back to input()..." ) session = None # type: ignore diff --git a/terminal.py b/terminal.py index dce53954d83..73f790cd755 100644 --- a/terminal.py +++ b/terminal.py @@ -13,6 +13,7 @@ from typing import List from pathlib import Path import dotenv +from prompt_toolkit import PromptSession from prompt_toolkit.completion import NestedCompleter from prompt_toolkit.styles import Style from prompt_toolkit.formatted_text import HTML @@ -224,7 +225,10 @@ class TerminalController(BaseController): start = time.time() console.print(f"\n[yellow]{task}[/yellow]\n") - an_input = session.prompt("GUESS / $ ") + if isinstance(session, PromptSession): + an_input = session.prompt("GUESS / $ ") + else: + an_input = "" time_dif = time.time() - start # When there are multiple paths to same solution