Skip to content

Commit 7bd8481

Browse files
Run black on specific paths
This keeps it from losing its mind if you have a virtualenv with unformatted python code sitting in the project directory.
1 parent d218283 commit 7bd8481

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

code_format.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
#!/usr/bin/env python3
22
import argparse
33
import black
4+
import glob
45
import subprocess
56
from pathlib import Path
67

78
PROJECT_DIR = Path(__file__).parent.resolve()
89
SCUBAINIT_DIR = PROJECT_DIR / "scubainit"
10+
PYTHON_CODE = (
11+
"scuba",
12+
"tests",
13+
"*.py",
14+
)
915

1016

1117
def _run_black(fix: bool) -> bool:
12-
args = [
13-
str(PROJECT_DIR),
14-
]
18+
args = []
19+
for pat in PYTHON_CODE:
20+
args += glob.glob(pat, root_dir=PROJECT_DIR)
1521

1622
if not fix:
1723
# check only

0 commit comments

Comments
 (0)