Repository navigation
Restore the 0.86.0 dialect flag reads and constructor field ordering under --strip-default-none - #5394
Conversation
… had, so a draft-07 document no longer decides it for the 2020-12 documents of a directory
… when ordering constructor fields inside the module loop
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Construction-default ordering src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/parser/_passes/render_prep.py, docs/architecture.md |
The ordering context tracks construction defaults separately from rendered nullability. The render-preparation pass applies this context during early ordering. |
Constructor output expectations tests/data/expected/main/openapi/.../strip_default_none_constructor_order[*].py, tests/data/expected/main/openapi/.../base-override-drops-inherited-default/*, tests/main/openapi/test_main_openapi.py, tests/main/openapi/test_main_openapi.refs |
Updated expected outputs show affected None-default fields as keyword-only. OpenAPI test descriptions and fixture references reflect the constructor-ordering cases. |
JSON Schema Reference Sibling Dialects
| Layer / File(s) | Summary |
|---|---|
Root-specific dialect detection src/datamodel_code_generator/parser/jsonschema.py |
A shared helper selects an explicit configured version or detects the supplied root’s version. The sibling check evaluates the current root. |
Mixed-dialect generation expectations tests/main/jsonschema/test_main_jsonschema.py, tests/main/jsonschema/test_main_jsonschema.refs, tests/data/expected/main/jsonschema/.../ref_sibling_dialect_directory[*]/*, tests/main/test_payload_validation.refs |
Tests and generated expectations cover mixed-dialect documents across dataclasses, msgspec, Pydantic BaseModel, Pydantic dataclass, and TypedDict. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Merge Risk: 
Minimal · previous review c3498
-
The constructor change matches the intended ordering behavior. No identified issue blocks merging after normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 22 files. (7 skipped: 4 unsupported, 3 too large.)
-
Finishing Touches: 💡 1
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merging this PR will improve performance by 30.37%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Breaking Change AnalysisResult: Breaking changes detected Reasoning: I read the whole diff. It makes two changes. First, in the JSON Schema parser, the check for whether keywords beside a $ref count as part of the schema now uses the dialect of the document being parsed, not a value cached from the first document. The new test says this restores the 0.86.0 behavior for a 2020-12 document read after a draft-07 one, so I treat it as a regression fix, not a breaking change. Second, a new context variable makes the early constructor ordering for Pydantic dataclasses count a None default that strip-default-none may keep as no default. The early ordering is the one used when order-constructor-fields-by final-names is off, which is the default. The expected outputs change visibly. In strip_default_none_constructor_order, a subclass field after an inherited default goes from a positional None default to Field(None, kw_only=True). In the type-overrides modules default case, subclass fields that were keyword-only now stay positional. A field turning keyword-only changes the generated constructor signature and breaks callers that pass that field positionally, so I report it as a code generation change. No CLI options, public API, templates or Python version support are removed or changed. Deleting the Windows msgspec observation snapshot and adding the refs entries only affects test infrastructure. Content for Release NotesCode Generation Changes
This analysis was produced by the release draft workflow |
Summary by CodeRabbit
$refsibling handling when processing directories containing documents from different schema drafts. Draft 4, 6, and 7 continue to follow their specific sibling-keyword rules.Nonedefaults, including inherited and overridden fields.