From c778b44edc084308ac7cb36da3559371d562a1ed Mon Sep 17 00:00:00 2001 From: SafetyQuincyF Date: Thu, 31 Oct 2024 14:25:34 -0700 Subject: [PATCH] fix --- safety/auth/utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/safety/auth/utils.py b/safety/auth/utils.py index d5388aae..5a8a3ba0 100644 --- a/safety/auth/utils.py +++ b/safety/auth/utils.py @@ -439,15 +439,15 @@ def is_jupyter_notebook() -> bool: try: from IPython import get_ipython shell = get_ipython() - - # Ensure that get_ipython() returned a valid shell instance - if shell is None: - return False - - # Check for presence of 'IPKernelApp', indicating a Jupyter notebook environment. - # This excludes cases where IPython is used in non-notebook environments. - return shell.__class__.__name__ == 'ZMQInteractiveShell' - - except (ImportError, NameError, AttributeError): - # IPython is not available, or the shell instance lacks required attributes. - return False \ No newline at end of file + if shell: + shell_name = shell.__class__.__name__ + if shell_name == "ZMQInteractiveShell": + print("Running in a Jupyter Notebook!") + elif shell_name == "TerminalInteractiveShell": + print("Running in an IPython terminal!") + else: + print("Running in a different IPython environment!") + else: + print("Not running in an IPython environment.") + except ImportError: + print("IPython is not installed. Running in a standard Python environment.") \ No newline at end of file