Skip to content

Commit 3f840f3

Browse files
authored
Merge pull request #1217 from seeM/fix-1188
use `ValueError` instead of `NotImplementedError` in `nbdev.doclinks._iter_py_cells`
2 parents effa1ee + d90dfa8 commit 3f840f3

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

nbdev/doclinks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ def _iter_py_cells(p):
5050
for cell in cells[1:]:
5151
top,code = cell.split('\n', 1)
5252
try: nb,idx = top.split()
53-
except ValueError:
54-
raise NotImplementedError(f"Unexpected format in '{p}' at cell:\n```\n# %% {cell.strip()}.\n```\n"
55-
"The expected format is: '# %% {nb_path} {cell_idx}'.")
53+
except ValueError: raise ValueError(f"Unexpected format in '{p}' at cell:\n```\n# %% {cell.strip()}.\n```\n"
54+
"The expected format is: '# %% {nb_path} {cell_idx}'.")
5655
nb_path = None if nb=='auto' else (p.parent/nb).resolve() # NB paths are stored relative to .py file
5756
if code.endswith('\n'): code=code[:-1]
5857
yield AttrDict(nb=nb, idx=int(idx), code=code, nb_path=nb_path, py_path=p.resolve())

nbs/api/doclinks.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@
138138
" for cell in cells[1:]:\n",
139139
" top,code = cell.split('\\n', 1)\n",
140140
" try: nb,idx = top.split()\n",
141-
" except ValueError:\n",
142-
" raise NotImplementedError(f\"Unexpected format in '{p}' at cell:\\n```\\n# %% {cell.strip()}.\\n```\\n\"\n",
143-
" \"The expected format is: '# %% {nb_path} {cell_idx}'.\")\n",
141+
" except ValueError: raise ValueError(f\"Unexpected format in '{p}' at cell:\\n```\\n# %% {cell.strip()}.\\n```\\n\"\n",
142+
" \"The expected format is: '# %% {nb_path} {cell_idx}'.\")\n",
144143
" nb_path = None if nb=='auto' else (p.parent/nb).resolve() # NB paths are stored relative to .py file\n",
145144
" if code.endswith('\\n'): code=code[:-1]\n",
146145
" yield AttrDict(nb=nb, idx=int(idx), code=code, nb_path=nb_path, py_path=p.resolve())"

0 commit comments

Comments
 (0)