Skip to content

Commit 8d811ee

Browse files
committed
add pre-commit
1 parent e9f2c0b commit 8d811ee

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.12.0
4+
hooks:
5+
- id: black-jupyter
6+
types_or: ["python","jupyter"]
7+
- repo: https://github.com/pycqa/isort
8+
rev: 5.12.0
9+
hooks:
10+
- id: isort
11+
- repo: https://github.com/PyCQA/autoflake
12+
rev: v2.0.2
13+
hooks:
14+
- id: autoflake
15+
- repo: https://github.com/floatingpurr/sync_with_poetry
16+
rev: 1.1.0
17+
hooks:
18+
- id: sync_with_poetry
19+
args: [
20+
'--all', # Scan all dependencies in poetry.lock (main and dev)
21+
]
22+
- repo: https://github.com/nbQA-dev/nbQA
23+
rev: 1.3.1
24+
hooks:
25+
- id: nbqa-isort # isort for jupyter

make_pdf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,10 @@ def replace_string_between(s, start_str, end_str, with_str):
8585
# Tweak html for rendering
8686

8787
# Remove hypothesis
88-
s = s.replace(
89-
'<script src="https://hypothes.is/embed.js" async></script>', ""
90-
)
88+
s = s.replace('<script src="https://hypothes.is/embed.js" async></script>', "")
9189

9290
# links to data should point to online version
93-
s = s.replace(
94-
'href="data/', f'href="http://{basename}.csail.mit.edu/data/'
95-
)
91+
s = s.replace('href="data/', f'href="http://{basename}.csail.mit.edu/data/')
9692

9793
write_file_as_string(filename, s)
9894
# os.system(f"node {os.path.join(root, 'htmlbook/render_html.js')} http://{basename}.csail.mit.edu/{c}.html {filename}")

tools/jupyter/nbconvert_script.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
import sys
77
import warnings
8-
from pathlib import Path
98

109
warnings.filterwarnings("ignore", category=SyntaxWarning)
1110

update_shas.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
if not notebooks:
2424
for path in pathlib.Path(root).rglob("*.ipynb"):
2525
p = str(path.relative_to(root))
26-
if any(
27-
s in p
28-
for s in [".history", "bazel", "figures", ".ipynb_checkpoints"]
29-
):
26+
if any(s in p for s in [".history", "bazel", "figures", ".ipynb_checkpoints"]):
3027
continue
3128
notebooks.append(p)
3229

0 commit comments

Comments
 (0)