We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 07d77b3 commit 1d11c82Copy full SHA for 1d11c82
scripts/nblint.py
@@ -30,9 +30,12 @@ def nblint():
30
nb_text = nb_path.read_text()
31
nb_node = nbformat.reads(nb_text, 4)
32
changes = 0
33
+ has_empty = 0
34
for cell in nb_node.cells:
35
cell_type = cell["cell_type"]
36
source = "".join(cell["source"])
37
+ if not source.strip():
38
+ has_empty += 1
39
if cell_type == "markdown":
40
prettier = subprocess.Popen(
41
[
@@ -63,6 +66,13 @@ def nblint():
63
66
if new != source:
64
67
cell["source"] = new.splitlines(True)
65
68
changes += 1
69
+
70
+ if has_empty:
71
+ changes += 1
72
+ nb_node.cells = [
73
+ cell for cell in nb_node.cells if "".join(cell["source"]).strip()
74
+ ]
75
76
if changes:
77
with nb_path.open("w") as fpt:
78
nbformat.write(nb_node, fpt)
0 commit comments