Skip to content

Commit f5874c6

Browse files
authored
Merge pull request #732 from dleen/master
non-notebooks do not have nbformat field
2 parents 8989e7b + d1f19b8 commit f5874c6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nbdev/clean.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def clean_jupyter(path, model, **kwargs):
127127
except FileNotFoundError: return
128128
in_nbdev_repo = 'nbs_path' in cfg
129129
jupyter_hooks = str2bool(cfg.get('jupyter_hooks', True))
130-
is_nb_v4 = (model['type'],model['content']['nbformat']) == ('notebook',4)
130+
if model['type'] != 'notebook': return
131+
is_nb_v4 = model['content']['nbformat'] == 4
131132
if in_nbdev_repo and jupyter_hooks and is_nb_v4: _nbdev_clean(model['content'])
132133

133134
# %% ../nbs/11_clean.ipynb 26

nbs/11_clean.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@
340340
" except FileNotFoundError: return\n",
341341
" in_nbdev_repo = 'nbs_path' in cfg\n",
342342
" jupyter_hooks = str2bool(cfg.get('jupyter_hooks', True))\n",
343-
" is_nb_v4 = (model['type'],model['content']['nbformat']) == ('notebook',4)\n",
343+
" if model['type'] != 'notebook': return\n",
344+
" is_nb_v4 = model['content']['nbformat'] == 4\n",
344345
" if in_nbdev_repo and jupyter_hooks and is_nb_v4: _nbdev_clean(model['content'])"
345346
]
346347
},

0 commit comments

Comments
 (0)