Skip to content

Commit

Permalink
imports fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ayasyrev committed Oct 28, 2023
1 parent e34a660 commit 253e1ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/nbmetaclean/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from pathlib import Path
from typing import Optional, Union

import nbformat

from nbformat.notebooknode import NotebookNode

from .core import read_nb, write_nb, PathOrStr
Expand Down Expand Up @@ -132,7 +130,6 @@ def clean_nb_file(
clear_execution_count: bool = True,
clear_outputs: bool = False,
preserve_timestamp: bool = True,
as_version: nbformat.Sentinel = nbformat.NO_CONVERT,
silent: bool = False,
) -> list[Path]:
"""Clean metadata and execution count from notebook.
Expand All @@ -155,7 +152,6 @@ def clean_nb_file(
cleaned: list[Path] = []
to_clean = len(path)
for num, filename in enumerate(path):
# description=f"cleaning {len(path)} nbs",
nb = read_nb(filename)
nb, result = clean_nb(
nb,
Expand All @@ -168,7 +164,7 @@ def clean_nb_file(
cleaned.append(filename)
if preserve_timestamp:
stat = filename.stat()
write_nb(nb, filename, as_version)
write_nb(nb, filename)
if preserve_timestamp:
os.utime(filename, (stat.st_atime, stat.st_mtime))
if not silent:
Expand Down
3 changes: 1 addition & 2 deletions src/nbmetaclean/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def read_nb(path: PathOrStr) -> NotebookNode:
def write_nb(
nb: NotebookNode,
path: PathOrStr,
as_version: nbformat.Sentinel = nbformat.NO_CONVERT,
) -> Path:
"""Write notebook to file
Expand All @@ -41,7 +40,7 @@ def write_nb(
if filename.suffix != ".ipynb":
filename = filename.with_suffix(".ipynb")
with filename.open("w", encoding="utf-8") as fh:
nbformat.write(nb, fh, version=as_version) # type: ignore
nbformat.write(nb, fh) # type: ignore
return filename


Expand Down

0 comments on commit 253e1ec

Please sign in to comment.