Skip to content

Commit 07da907

Browse files
committed
💚 Fix
1 parent d0bbaac commit 07da907

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎nbproject/dev/_jupyter_communicate.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def find_nb_path_via_parent_process():
121121
if arg.endswith(".ipynb"):
122122
potential_path = arg # Store the last one found
123123

124+
if is_nbconvert_call and "--inplace" not in cmdline:
125+
raise ValueError("Please execute 'nbconvert' with option '--inplace'.")
126+
124127
if is_nbconvert_call and potential_path:
125128
# We found something that looks like an nbconvert call and an ipynb file
126129
# The path might be relative to the parent process's CWD.
@@ -169,6 +172,8 @@ def find_nb_path_via_parent_process():
169172
except psutil.Error as e:
170173
logger.warning(f"psutil error: {e}")
171174
return None
175+
except ValueError as ve: # Explicitly catch and re-raise the intended error
176+
raise ve
172177
except Exception as e:
173178
logger.warning(f"Unexpected error during psutil check: {e}")
174179
return None

‎tests/test_nbconvert.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@ def test_running_via_nbconvert():
1010
)
1111
print(result.stdout.decode())
1212
print(result.stderr.decode())
13-
assert result.returncode == 0
13+
assert result.returncode == 1
14+
assert (
15+
"Please execute 'nbconvert' with option '--inplace'." in result.stderr.decode()
16+
)
17+
18+
result = subprocess.run(
19+
"jupyter nbconvert --to notebook --inplace --execute ./tests/for-nbconvert.ipynb",
20+
shell=True,
21+
capture_output=True,
22+
)
23+
print(result.stdout.decode())
24+
print(result.stderr.decode())
25+
assert result.returncode == 1

0 commit comments

Comments
 (0)