Skip to content

Commit 1ddd055

Browse files
authored
🚸 Error for nbconvert if --inplace is not passed (#289)
* βœ… Error for nbconvert if --inplace is not passed * Revert "βœ… Error for nbconvert if --inplace is not passed" This reverts commit 105d18a. * πŸ’š Fix * πŸ’š Fix * πŸ‘· Run CI on Python 3.13
1 parent b13513b commit 1ddd055

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

β€Ž.github/workflows/build.ymlβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ["3.10", "3.11"]
15+
python-version: ["3.10", "3.13"]
1616

1717
steps:
1818
- name: Checkout main
@@ -61,7 +61,7 @@ jobs:
6161
- run: nox -s build
6262

6363
- name: Codecov
64-
if: matrix.python-version == '3.11'
64+
if: matrix.python-version == '3.13'
6565
uses: codecov/codecov-action@v2
6666
with:
6767
token: ${{ secrets.CODECOV_TOKEN }}

β€Žnbproject/dev/_jupyter_communicate.pyβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ 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(
126+
"Please execute notebook 'nbconvert' by passing option '--inplace'."
127+
)
128+
124129
if is_nbconvert_call and potential_path:
125130
# We found something that looks like an nbconvert call and an ipynb file
126131
# The path might be relative to the parent process's CWD.
@@ -169,6 +174,8 @@ def find_nb_path_via_parent_process():
169174
except psutil.Error as e:
170175
logger.warning(f"psutil error: {e}")
171176
return None
177+
except ValueError as ve: # Explicitly catch and re-raise the intended error
178+
raise ve
172179
except Exception as e:
173180
logger.warning(f"Unexpected error during psutil check: {e}")
174181
return None

β€Žtests/test_nbconvert.pyβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ def test_running_via_nbconvert():
88
shell=True,
99
capture_output=True,
1010
)
11+
assert result.returncode == 1
12+
assert (
13+
"Please execute notebook 'nbconvert' by passing option '--inplace'."
14+
in result.stderr.decode()
15+
)
16+
17+
result = subprocess.run(
18+
"jupyter nbconvert --to notebook --inplace --execute ./tests/for-nbconvert.ipynb",
19+
shell=True,
20+
capture_output=True,
21+
)
1122
print(result.stdout.decode())
1223
print(result.stderr.decode())
1324
assert result.returncode == 0

0 commit comments

Comments
Β (0)