You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make a field required through the store op and read whether a root field is constrained in one place each - #5940
Koudai Aono (koxudaxi)
changed the title
next11 9
Make a field required through the store op and read whether a root field is constrained in one place each
Nov 1, 2026
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Walkthrough
Root-field constraint detection now distinguishes declared constraints from constraints consumed by the field type or direct members. Inherited-field and JSON Schema parsing paths now set required-field state through require_field.
Changes: Root Constraint Detection
Layer / File(s)
Summary
Constraint helper and consumers src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/_passes/modules.py, src/datamodel_code_generator/_target_binding.py, src/datamodel_code_generator/parser/base.py, docs/architecture.md
The root-field constraint helper moves to model.base and provides declared and with-consumed checks. Its consumers use the declared check where required. The architecture table documents both checks.
Inherited-field and JSON Schema parsing paths use require_field to set requiredness and default-handling state. The allowlist entries for direct field-state writes are removed, and the architecture table documents the operation.
No actionable merge-blocking issue is established for these refactors. Mergeability remains subject to normal build and test checks.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and accurately summarizes both main changes: centralizing required-field updates and root-field constraint checks.
Docstring Coverage
Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 6 files. (1 skipped: 1 unsupported.)
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
LanguageTool
docs/architecture.md
LanguageTool checks are incomplete because the per-file request limit of 5 was reached. Remaining text was skipped; findings from completed checks are retained.
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.
⚠️52 benchmarks with a significant change ran on different hardware
Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.
Reasoning: The diff is an internal refactor. The private helper _has_root_field_constraints moved from parser/_passes/_shared.py to model/base.py and gained a row parameter whose default keeps the old behaviour. The inline declared-constraints checks in _target_binding.py and collapse_site_facts now call it with row declared, which gives the same result. The direct assignments of field.required and use_default_with_required in jsonschema.py and _rw_split.py now go through GraphBuilder.require_field with what appear to be the same values, though at the jsonschema.py sites the old code never reset the default flag and the body of require_field is not in the diff, so that equivalence could not be fully confirmed. The other changes are documentation table rows and a generation store allowlist update. No public CLI options, Python API, templates, default values, Python version support or error handling are changed. The behaviour diff gate does show accepted cells, but they describe allOf schemas whose parts admit no object now becoming RootModel or a msgspec alias. The gate compares against the last release, so it includes changes merged since then, and this diff does not touch allOf handling, so those cells are not attributable to this PR. The remaining cells are crash-fix or both-fail, which do not change behaviour.
This analysis was produced by the release draft workflow
This PR is now available in the latest release. See the release notes for details.
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
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.
Summary by CodeRabbit
Bug Fixes
Documentation