Skip to content

fix(scripts): auto-format generated models in regenerate.py#14

Open
cubehouse wants to merge 1 commit intomainfrom
fix/regen-auto-format
Open

fix(scripts): auto-format generated models in regenerate.py#14
cubehouse wants to merge 1 commit intomainfrom
fix/regen-auto-format

Conversation

@cubehouse
Copy link
Copy Markdown
Member

Stops the recurring cosmetic spec-drift PRs from quote-style changes in datamodel-code-generator output.

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>
Copilot AI review requested due to automatic review settings April 22, 2026 11:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py to run ruff format on 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.

Comment thread scripts/regenerate.py
Comment on lines +166 to +170
print("Formatting generated models with ruff...")
subprocess.run(
[sys.executable, "-m", "ruff", "format", str(OUTPUT)],
check=True,
)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants