-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Bump datamodel-code-generator from 0.57.0 to 0.64.0 #3230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dependabot
wants to merge
1
commit into
main
Choose a base branch
from
dependabot/uv/datamodel-code-generator-0.64.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 --checkdrift gate fails for bothsrc/mcp-types/mcp_types/_v2025_11_25/__init__.pyand_v2026_07_28/__init__.py(0.64.0 emits new__pydantic_extra__/model_rebuild(force=True)blocks and changesJSONValuetoRootModel[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__.pyonly 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__.pyper-file-ignores with UP006/UP035/UP045 (or add aruff check --fixpass to the generator script); the semanticJSONValueOptional change in the regenerated output also deserves review.Extended reasoning...
What breaks
This PR bumps the
codegengroup pin fromdatamodel-code-generator==0.57.0to==0.64.0(pyproject.toml + uv.lock) but does not regenerate the checked-in generated modulessrc/mcp-types/mcp_types/_v2025_11_25/__init__.pyandsrc/mcp-types/mcp_types/_v2026_07_28/__init__.py. CI enforces byte-exact agreement between those files and fresh generator output:.github/workflows/shared.ymlrunsuv 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:
extra='allow'class it appendsX.__annotations__["__pydantic_extra__"] = Dict[str, Any]plusX.model_rebuild(force=True)— affectingGetTaskPayloadResult,Meta,Result,Datain_v2025_11_25andInputSchema,OutputSchema,Resultin_v2026_07_28.Dictto thetypingimport to support those lines.JSONValuein_v2026_07_28becomesclass JSONValue(RootModel[Optional[Union[...]]])— 0.64.0 emitsOptional[...]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, recursiveJSONValueworks).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 ofdict[str, Any]), 2× UP035 (deprecatedtyping.Dictimport — not auto-fixable), and 2× UP045 on the newJSONValueOptional(the base-class occurrence is not auto-fixable). The per-file-ignores forsrc/mcp-types/mcp_types/_v*/__init__.pyin pyproject.toml only coverD212, 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-filesbefore the drift check) runsruff 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 (Dict→dict), they no longer byte-match fresh generator output, becausescripts/gen_surface_types.pypost-processes only withruff format(around lines 255–260), neverruff 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
uv sync --group codegen --frozeninstalls datamodel-code-generator 0.64.0 (the new pin).uv run --frozen --group codegen python scripts/gen_surface_types.py --check→ exits 1, reporting drift in both_v2025_11_25/__init__.pyand_v2026_07_28/__init__.py(new__pydantic_extra__blocks,Dictimport,JSONValueOptional).scripts/gen_surface_types.py(no--check) to regenerate, thenruff checkwith 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.ruff check --fixand 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.pyand commit the regenerated_v2025_11_25and_v2026_07_28packages (reviewing theJSONValueOptionalchange), and (b) either extend thesrc/mcp-types/mcp_types/_v*/__init__.pyper-file-ignores withUP006,UP035,UP045(matching the precedent ofUP007/UP037, which exist for exactly this raw-codegen-output reason), or add aruff check --fixpass togen_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.