Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
# `griffe`; the old `griffe` distribution is the incompatible 1.x line.
"griffelib==2.1.0",
]
codegen = ["datamodel-code-generator==0.57.0"]
codegen = ["datamodel-code-generator==0.64.0"]

Check failure on line 106 in pyproject.toml

View check run for this annotation

Claude / Claude Code Review

Generator bump requires regenerating surface types and extending ruff per-file-ignores

Bumping datamodel-code-generator to 0.64.0 without regenerating the checked-in surface types breaks CI in two independent ways: the `gen_surface_types.py --check` drift gate fails for both `src/mcp-types/mcp_types/_v2025_11_25/__init__.py` and `_v2026_07_28/__init__.py` (0.64.0 emits new `__pydantic_extra__`/`model_rebuild(force=True)` blocks and changes `JSONValue` to `RootModel[Optional[Union[...]]]`), and even after regenerating, the new output violates the repo ruff config (7× UP006, 2× UP03

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Bumping datamodel-code-generator to 0.64.0 without regenerating the checked-in surface types breaks CI in two independent ways: the gen_surface_types.py --check drift gate fails for both src/mcp-types/mcp_types/_v2025_11_25/__init__.py and _v2026_07_28/__init__.py (0.64.0 emits new __pydantic_extra__/model_rebuild(force=True) blocks and changes JSONValue to RootModel[Optional[Union[...]]]), and even after regenerating, the new output violates the repo ruff config (7× UP006, 2× UP035, 2× UP045 — several not auto-fixable) while the per-file-ignores for _v*/__init__.py only cover D212/E501/I001/TID251/UP007/UP037, making the pre-commit lint hook and the byte-exact drift check mutually unsatisfiable. Fix: regenerate both surface packages in this PR and extend the _v*/__init__.py per-file-ignores with UP006/UP035/UP045 (or add a ruff check --fix pass to the generator script); the semantic JSONValue Optional change in the regenerated output also deserves review.

Extended reasoning...

What breaks

This PR bumps the codegen group pin from datamodel-code-generator==0.57.0 to ==0.64.0 (pyproject.toml + uv.lock) but does not regenerate the checked-in generated modules src/mcp-types/mcp_types/_v2025_11_25/__init__.py and src/mcp-types/mcp_types/_v2026_07_28/__init__.py. CI enforces byte-exact agreement between those files and fresh generator output: .github/workflows/shared.yml runs uv run --frozen --group codegen python scripts/gen_surface_types.py --check (the "Surface types match vendored schema" step). With 0.64.0 pinned, that check was reproduced at this PR's commit and exits 1 with drift in both files.

Why the output differs

datamodel-code-generator 0.64.0 changes its emitted code for this schema in three ways, none of which appear in the committed 0.57.0-generated files:

  1. For every extra='allow' class it appends X.__annotations__["__pydantic_extra__"] = Dict[str, Any] plus X.model_rebuild(force=True) — affecting GetTaskPayloadResult, Meta, Result, Data in _v2025_11_25 and InputSchema, OutputSchema, Result in _v2026_07_28.
  2. It adds Dict to the typing import to support those lines.
  3. JSONValue in _v2026_07_28 becomes class JSONValue(RootModel[Optional[Union[...]]]) — 0.64.0 emits Optional[...] here despite --use-union-operator. This is a semantic-looking change worth reviewing during regeneration, though the regenerated modules were verified to import and validate correctly at runtime (extras preserved on open classes, recursive JSONValue works).

Why regeneration alone still leaves CI red

Independently verified: after regenerating with 0.64.0, running the repo ruff config over the output at its real paths yields 11 errors, 8 auto-fixable — 7× UP006 (Dict[str, Any] instead of dict[str, Any]), 2× UP035 (deprecated typing.Dict import — not auto-fixable), and 2× UP045 on the new JSONValue Optional (the base-class occurrence is not auto-fixable). The per-file-ignores for src/mcp-types/mcp_types/_v*/__init__.py in pyproject.toml only cover D212, E501, I001, TID251, UP007, UP037 — none of the new codes.

This creates a deadlock between two CI gates. Pre-commit (run in CI on --all-files before the drift check) runs ruff check --fix --exit-non-zero-on-fix, so the 3 unfixable errors fail the hook outright and the 8 fixable ones trip --exit-non-zero-on-fix. But if you commit the --fixed files (Dictdict), they no longer byte-match fresh generator output, because scripts/gen_surface_types.py post-processes only with ruff format (around lines 255–260), never ruff check --fix — so the drift gate fails again. The committed files can satisfy the lint hook or the drift check, but not both, with the current config.

Step-by-step proof

  1. Check out this PR's commit; uv sync --group codegen --frozen installs datamodel-code-generator 0.64.0 (the new pin).
  2. Run the exact CI step: uv run --frozen --group codegen python scripts/gen_surface_types.py --check → exits 1, reporting drift in both _v2025_11_25/__init__.py and _v2026_07_28/__init__.py (new __pydantic_extra__ blocks, Dict import, JSONValue Optional).
  3. Run scripts/gen_surface_types.py (no --check) to regenerate, then ruff check with the repo config → 11 errors (7× UP006, 2× UP035, 2× UP045); UP035 and one UP045 are not auto-fixable, so pre-commit's ruff hook fails.
  4. Apply ruff check --fix and commit → step 2's drift gate fails again, since the generator pipeline never applies those fixes. No sequence of regenerate/fix steps makes both gates pass without a config or script change.

How to fix

In this PR: (a) run uv run --frozen --group codegen python scripts/gen_surface_types.py and commit the regenerated _v2025_11_25 and _v2026_07_28 packages (reviewing the JSONValue Optional change), and (b) either extend the src/mcp-types/mcp_types/_v*/__init__.py per-file-ignores with UP006, UP035, UP045 (matching the precedent of UP007/UP037, which exist for exactly this raw-codegen-output reason), or add a ruff check --fix pass to gen_surface_types.py's pipeline so generated output and lint-clean output coincide. This is a CI/tooling failure, not a runtime break — but without both changes the PR cannot merge.


[build-system]
requires = ["hatchling", "uv-dynamic-versioning"]
Expand Down
12 changes: 6 additions & 6 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading