fix(scripts): auto-format generated models in regenerate.py#14
fix(scripts): auto-format generated models in regenerate.py#14
Conversation
datamodel-code-generator's output quote style drifts between versions (double quotes vs single quotes), causing spec-drift PRs that are pure formatting noise. Run `ruff format` on the generated file as part of the regenerate pipeline so the output always matches the project's style and CI's `ruff format --check` stays green. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent recurring cosmetic “spec drift” diffs in the autogenerated Pydantic models by ensuring the generated output is auto-formatted to match the repo’s Ruff formatting rules.
Changes:
- Reformat generated model enums to Ruff’s preferred quoting style (double quotes).
- Update
scripts/regenerate.pyto runruff formaton the generated models after applying post-generation patches.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
themeparks/_generated/models.py |
Generated output reformatted (primarily quote-style normalization) to align with Ruff formatter output. |
scripts/regenerate.py |
Adds a post-generation Ruff formatting step to keep generated models consistent with CI formatting checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| print("Formatting generated models with ruff...") | ||
| subprocess.run( | ||
| [sys.executable, "-m", "ruff", "format", str(OUTPUT)], | ||
| check=True, | ||
| ) |
There was a problem hiding this comment.
ruff format will resolve configuration (pyproject.toml) relative to the current working directory. Since this script otherwise supports being run from any directory (it uses absolute OUTPUT), running it from outside the repo root could format with Ruff defaults (e.g., different line length) and reintroduce CI drift. Consider passing cwd pointing at the project root or providing --config with the resolved pyproject.toml path to make formatting deterministic.
Stops the recurring cosmetic spec-drift PRs from quote-style changes in datamodel-code-generator output.