Skip to content

Commit 446c7c5

Browse files
committed
Remove Prettier calls from Python scripts - formatting handled by pre-commit hook
1 parent 36638c4 commit 446c7c5

File tree

4 files changed

+4
-53
lines changed

4 files changed

+4
-53
lines changed

scripts/normalize_book_sets.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import json
1414
import os
1515
import argparse
16-
import subprocess
1716
from pathlib import Path
1817

1918

@@ -300,22 +299,10 @@ def normalize_book_sets(
300299
print("[DRY RUN] Would write changes to file (use --write to apply)")
301300
else:
302301
try:
303-
# Write JSON file (prettier will format it)
302+
# Write JSON file (prettier will format it via pre-commit hook)
304303
with open(book_sets_file, "w", encoding="utf-8") as f:
305304
json.dump(data, f, ensure_ascii=False)
306305

307-
# Format with prettier
308-
try:
309-
subprocess.run(
310-
["npx", "prettier", "--write", book_sets_file],
311-
check=True,
312-
capture_output=True,
313-
)
314-
except subprocess.CalledProcessError as e:
315-
print(f"Warning: Prettier formatting failed: {e}")
316-
except FileNotFoundError:
317-
print("Warning: npx/prettier not found, skipping formatting")
318-
319306
print("\n" + "=" * 70)
320307
print(f"✓ Successfully updated '{book_sets_file}'")
321308
except Exception as e:

scripts/normalize_json.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import json
1212
import argparse
13-
import subprocess
1413
from collections import OrderedDict
1514

1615

@@ -33,20 +32,10 @@ def sort_json_by_numeric_keys(input_file, output_file):
3332
sorted_items = sorted(data.items(), key=lambda item: int(item[0]))
3433
sorted_data = OrderedDict(sorted_items)
3534

36-
# Write JSON (Prettier will format it)
35+
# Write JSON (Prettier will format it via pre-commit hook)
3736
with open(output_file, "w", encoding="utf-8") as f:
3837
json.dump(sorted_data, f, ensure_ascii=False)
3938

40-
# Format with prettier
41-
try:
42-
subprocess.run(
43-
["npx", "prettier", "--write", output_file],
44-
check=True,
45-
capture_output=True,
46-
)
47-
except (subprocess.CalledProcessError, FileNotFoundError):
48-
pass # Silently fail if prettier is not available
49-
5039
print(
5140
f"Successfully sorted '{input_file}' and saved the result to '{output_file}'."
5241
)

scripts/sort_book_sets_by_difficulty.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import sys
1919
import argparse
20-
import subprocess
2120
from pathlib import Path
2221

2322
# Paths
@@ -184,22 +183,9 @@ def main():
184183
print(f"Dry run complete. Would update {updated_count} set(s).")
185184
else:
186185
if updated_count > 0:
187-
# Save updated book-sets.json
186+
# Save updated book-sets.json (Prettier will format it via pre-commit hook)
188187
with open(BOOK_SETS_PATH, "w", encoding="utf-8") as f:
189188
json.dump(book_sets, f, ensure_ascii=False)
190-
191-
# Format with prettier
192-
try:
193-
subprocess.run(
194-
["npx", "prettier", "--write", str(BOOK_SETS_PATH)],
195-
check=True,
196-
capture_output=True,
197-
)
198-
except subprocess.CalledProcessError as e:
199-
print(f"Warning: Prettier formatting failed: {e}")
200-
except FileNotFoundError:
201-
print("Warning: npx/prettier not found, skipping formatting")
202-
203189
print(f"✓ Updated {updated_count} book set(s) in {BOOK_SETS_PATH}")
204190
else:
205191
print("No changes needed. All sets are already sorted.")

scripts/update_problems_from_csv.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,9 @@ def save_json(data):
156156
)
157157
sorted_data = OrderedDict(sorted_items)
158158

159+
# Write JSON (Prettier will format it via pre-commit hook)
159160
with open(JSON_PATH, "w", encoding="utf-8") as f:
160161
json.dump(sorted_data, f, ensure_ascii=False)
161-
162-
# Format with prettier
163-
import subprocess
164-
try:
165-
subprocess.run(
166-
["npx", "prettier", "--write", str(JSON_PATH)],
167-
check=True,
168-
capture_output=True,
169-
)
170-
except (subprocess.CalledProcessError, FileNotFoundError):
171-
pass # Silently fail if prettier is not available
172-
173162
return True
174163
except Exception as e:
175164
print(f"Error saving JSON: {e}")

0 commit comments

Comments
 (0)