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 525a04d commit d09854f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions safety/auth/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from functools import lru_cache
import json
import logging
from typing import Any, Optional, Dict, Callable, Tuple
Expand Down Expand Up @@ -427,12 +428,18 @@ def send(self, request: requests.PreparedRequest, **kwargs: Any) -> requests.Res
return super().send(request, **kwargs)


@lru_cache(maxsize=1)
def is_jupyter_notebook() -> bool:
"""Check if the code is being executed inside a Jupyter Notebook."""
"""
Check if the code is being executed inside a Jupyter Notebook.
Returns:
bool: True if running in a Jupyter notebook, False otherwise.
"""
try:
from IPython import get_ipython
if 'IPKernelApp' not in get_ipython().config:
return False
except Exception:
return False
from IPython import get_ipython
if 'IPKernelApp' not in get_ipython().config:
return False
except (ImportError, AttributeError):
return False
return True

0 comments on commit d09854f

Please sign in to comment.