Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SafetyQuincyF committed Oct 31, 2024
1 parent 60dbecd commit c778b44
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions safety/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.")

0 comments on commit c778b44

Please sign in to comment.