Found during review of #178 (T2-4).
scaffold_from_template copies the template tycoon.yml with shutil.copy2, which preserves the file verbatim — then immediately undoes that with a yaml.safe_load / yaml.dump round-trip to stamp schema_version:
shutil.copy2(src_yml, dst_yml)
_raw = yaml.safe_load(dst_yml.read_text()) or {}
_raw["schema_version"] = SCHEMA_VERSION
dst_yml.write_text(yaml.dump(_raw, default_flow_style=False, sort_keys=False))
Effect
Verified against src/tycoon/templates/nyc-transit/tycoon.yml:
- 41 lines → 37
- all 5 blank-line section separators stripped, so the file arrives as one dense block
schema_version appended at line 36, at the bottom, rather than next to version: at the top
This is the first file a new user opens after tycoon init --template.
Why it's inconsistent
migrate_project deliberately uses ruamel.yaml precisely to preserve comments and blank lines. This path throws that away for the same stamping job.
Suggested fix
Drop the manual round-trip and call migrate_project(dst_yml.parent) after the copy. It's ruamel-based, already tested, idempotent, and stamps schema_version plus metadata: defaults in one shot.
scaffold_blank_project is unaffected — it builds the dict itself, so there's no formatting to preserve.
Mirrored in Jira: PTC-110 (Subtask of PTC-84, [Rewrite M2]). Dev work continues here.
Found during review of #178 (T2-4).
scaffold_from_templatecopies the templatetycoon.ymlwithshutil.copy2, which preserves the file verbatim — then immediately undoes that with ayaml.safe_load/yaml.dumpround-trip to stampschema_version:Effect
Verified against
src/tycoon/templates/nyc-transit/tycoon.yml:schema_versionappended at line 36, at the bottom, rather than next toversion:at the topThis is the first file a new user opens after
tycoon init --template.Why it's inconsistent
migrate_projectdeliberately uses ruamel.yaml precisely to preserve comments and blank lines. This path throws that away for the same stamping job.Suggested fix
Drop the manual round-trip and call
migrate_project(dst_yml.parent)after the copy. It's ruamel-based, already tested, idempotent, and stampsschema_versionplusmetadata:defaults in one shot.scaffold_blank_projectis unaffected — it builds the dict itself, so there's no formatting to preserve.Mirrored in Jira: PTC-110 (Subtask of PTC-84, [Rewrite M2]). Dev work continues here.