Skip to content

Commit

Permalink
fixes #1414
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed May 25, 2024
1 parent 159f550 commit b42fa70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 4 additions & 2 deletions nbdev/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def nbdev_trust(
import warnings
warnings.warn("Please install jupyter and try again")
return
from nbformat import read

fname = Path(fname if fname else get_config().nbs_path)
path = fname if fname.is_dir() else fname.parent
Expand All @@ -40,7 +41,7 @@ def nbdev_trust(
if last_checked and not force_all:
last_changed = os.path.getmtime(fn)
if last_changed < last_checked: continue
nb = read_nb(fn)
with open(fn, 'r', encoding='utf-8') as f: nb = read(f, as_version=4)
if not NotebookNotary().check_signature(nb): NotebookNotary().sign(nb)
check_fname.touch(exist_ok=True)

Expand Down Expand Up @@ -121,7 +122,8 @@ def _nbdev_clean(nb, path=None, clear_all=None):
clear_all = clear_all or cfg.clear_all
allowed_metadata_keys = cfg.get("allowed_metadata_keys").split()
allowed_cell_metadata_keys = cfg.get("allowed_cell_metadata_keys").split()
return clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)
clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)
if path: nbdev_trust.__wrapped__(path)

# %% ../nbs/api/11_clean.ipynb 29
@call_parse
Expand Down
14 changes: 4 additions & 10 deletions nbs/api/11_clean.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
" import warnings\n",
" warnings.warn(\"Please install jupyter and try again\")\n",
" return\n",
" from nbformat import read\n",
"\n",
" fname = Path(fname if fname else get_config().nbs_path)\n",
" path = fname if fname.is_dir() else fname.parent\n",
Expand All @@ -92,7 +93,7 @@
" if last_checked and not force_all:\n",
" last_changed = os.path.getmtime(fn)\n",
" if last_changed < last_checked: continue\n",
" nb = read_nb(fn)\n",
" with open(fn, 'r', encoding='utf-8') as f: nb = read(f, as_version=4)\n",
" if not NotebookNotary().check_signature(nb): NotebookNotary().sign(nb)\n",
" check_fname.touch(exist_ok=True)"
]
Expand Down Expand Up @@ -209,7 +210,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down Expand Up @@ -375,7 +375,8 @@
" clear_all = clear_all or cfg.clear_all\n",
" allowed_metadata_keys = cfg.get(\"allowed_metadata_keys\").split()\n",
" allowed_cell_metadata_keys = cfg.get(\"allowed_cell_metadata_keys\").split()\n",
" return clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)"
" clean_nb(nb, clear_all, allowed_metadata_keys, allowed_cell_metadata_keys, cfg.clean_ids)\n",
" if path: nbdev_trust.__wrapped__(path)"
]
},
{
Expand Down Expand Up @@ -826,13 +827,6 @@
"#|hide\n",
"import nbdev; nbdev.nbdev_export()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ black_formatting = False
readme_nb = getting_started.ipynb
allowed_metadata_keys =
allowed_cell_metadata_keys =
jupyter_hooks = False
jupyter_hooks = True
clean_ids = False
clear_all = False
put_version_in_init = True
Expand Down

0 comments on commit b42fa70

Please sign in to comment.