Skip to content

Commit 3a97f4d

Browse files
bokelleyclaude
andcommitted
fix: exclude _generated.py from black pre-commit hook
The schema validation CI was failing because pre-commit's black hook was reformatting the generated _generated.py file, splitting single-line imports into multi-line format. The file was already excluded in pyproject.toml but pre-commit hooks need their own exclude patterns. Added explicit exclude pattern to prevent black from reformatting this auto-generated file. Also updated consolidate_exports.py to attempt running black (for local development) but this is now a no-op since black is configured to skip the file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd3cc4e commit 3a97f4d

File tree

3 files changed

+116
-476
lines changed

3 files changed

+116
-476
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repos:
1010
- id: black
1111
language_version: python3.11
1212
args: [--line-length=100]
13+
exclude: ^src/adcp/types/_generated\.py$
1314

1415
# Ruff linting (ignoring line-length for now - black handles it)
1516
- repo: https://github.com/astral-sh/ruff-pre-commit

scripts/consolidate_exports.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from __future__ import annotations
1010

1111
import ast
12+
import subprocess
13+
import sys
1214
from datetime import datetime, timezone
1315
from pathlib import Path
1416

@@ -257,6 +259,22 @@ def main():
257259
print(f"\nWriting {OUTPUT_FILE}...")
258260
OUTPUT_FILE.write_text(content)
259261

262+
# Run black to format the generated file
263+
print("Formatting with black...")
264+
try:
265+
result = subprocess.run(
266+
[sys.executable, "-m", "black", str(OUTPUT_FILE), "--quiet"],
267+
capture_output=True,
268+
text=True,
269+
check=False,
270+
)
271+
if result.returncode == 0:
272+
print("✓ Formatted with black")
273+
else:
274+
print(f"⚠ Black formatting had issues: {result.stderr}")
275+
except Exception as e:
276+
print(f"⚠ Could not run black (not critical): {e}")
277+
260278
print("✓ Successfully generated consolidated exports")
261279
export_count = len(
262280
[

0 commit comments

Comments
 (0)