Skip to content

Commit

Permalink
Throw exception if used in interactive environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
eskildsf committed Dec 20, 2024
1 parent 51a5d78 commit b1b45a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions reloading/reloading.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def __iter__(self):
)


def is_interactive():
return hasattr(sys, "ps1")


class ReloadingException(Exception):
pass

Expand Down Expand Up @@ -81,6 +85,9 @@ def reloading(fn_or_seq_or_bool: Optional[
A function, iterator or condition which should be reloaded from
source before each invocation or iteration, respectively.
"""
if is_interactive():
raise Exception('Reloading cannot be used in interactive '
'prompt or IPython.')
if fn_or_seq_or_bool is not None:
if isinstance(fn_or_seq_or_bool, Callable):
return _reloading_function(fn_or_seq_or_bool)
Expand Down

0 comments on commit b1b45a5

Please sign in to comment.