Defer model build#447
Open
DamianCzajkowski wants to merge 10 commits into
Open
Conversation
…core lock - add hatch check-code/check-fmt/check-types static-analysis envs pinned to the project ruff, replacing the deprecated `hatch fmt` - register the `performance` marker and deselect it by default (timing guards are too noisy for shared CI; run with `hatch test -- -m performance`) - refresh uv.lock to graphql-core 3.2.11, matching the committed schema fixtures
`_copy_files` keyed the base-model rewrite off `source_path.name == "base_model.py"`, but with `multipart_uploads = false` the base model is copied from `base_model_no_upload.py`. The check was therefore false, so `defer_model_build` (and `ignore_extra_fields = false`) were silently dropped from the generated `BaseModel` while the settings summary still reported them as enabled. Key the rewrite off the base-model source path instead, so it fires in both upload modes.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Kwaidan00
reviewed
Jul 20, 2026
Kwaidan00
approved these changes
Jul 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds an opt-in
defer_model_buildsetting (defaultfalse) that makes importinga generated package much faster for large schemas, plus the build/tooling and
correctness fixes the change that rests on.
What it adds
defer_model_buildsetting when enabled:defer_build=Trueon the generatedBaseModel, so each model's coreThe schema is built on first use instead of at import time;
Model.model_rebuild()calls from the generated modules.For a large schema, this cuts import time roughly in half, since importing the
package no longer builds every Pydantic model up front. It's fully opt-in and
changes no generated code until you set it. Requires
pydantic >= 2.9in theenvironment that runs the generated package (
defer_buildis not aConfigDictkey before 2.5).