Skip to content

Commit 4743741

Browse files
rustyconoverclaude
andcommitted
fix(codegen): emit gofmt-clean Go schemas
Empty schemas now collapse to []arrow.Field{} on one line, and there is no trailing blank line at EOF — gofmt rejects both forms and vgi-go's CI runs gofmt -l. Surfaced by the macro arguments_schema regen. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2fcf21a commit 4743741

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎vgi/codegen/go_schemas.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ def _emit_field_literal(field: pa.Field[Any], *, origin: str) -> str:
155155

156156
def _emit_var(es: EmittedSchema) -> str:
157157
body = f"// Origin: {es.origin}\n"
158+
fields = list(es.schema)
159+
# Empty schemas must collapse to `[]arrow.Field{}` on one line — gofmt
160+
# rejects the multi-line `{\n}` form, and vgi-go's CI runs `gofmt -l`.
161+
if not fields:
162+
body += f"var {es.name}Schema = arrow.NewSchema([]arrow.Field{{}}, nil)\n"
163+
return body
158164
body += f"var {es.name}Schema = arrow.NewSchema([]arrow.Field{{\n"
159-
for f in es.schema:
165+
for f in fields:
160166
body += "\t" + _emit_field_literal(f, origin=f"{es.name}.{f.name}") + ",\n"
161167
body += "}, nil)\n"
162168
return body
@@ -178,9 +184,9 @@ def emit(out: TextIO) -> None:
178184
body.write("\n")
179185
body.write("var _ = arrow.BinaryTypes.String // keep import live when no schemas reference it\n")
180186
body.write("\n")
181-
for block in (_emit_var(es) for es in schemas):
182-
body.write(block)
183-
body.write("\n")
187+
# Blank line BETWEEN blocks, but no trailing blank line at EOF (gofmt rejects
188+
# it; vgi-go CI runs `gofmt -l`). Each block already ends in "\n".
189+
body.write("\n".join(_emit_var(es) for es in schemas))
184190

185191
out.write(
186192
provenance_comment(

0 commit comments

Comments
 (0)