Skip to content

Share the reference rebinding, the run arguments and the orderings of the structure, render preparation, settle and cross-module passes - #5572

Merged
Koudai Aono (koxudaxi) merged 1 commit into
dry-r36from
dry-r34
Oct 29, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
dry-r36from
dry-r34

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of circular and cross-module references in generated models.
    • Corrected generic base class assignment for models that inherit from other generated models.
    • Improved deserialization of decimal default values.

… the structure, render preparation, settle and cross-module passes
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 0f2e122 and 03c43fb.

Files selected for processing: 9
  • src/datamodel_code_generator/parser/_passes/_shared.py
  • src/datamodel_code_generator/parser/_passes/_state.py
  • src/datamodel_code_generator/parser/_passes/_tables.py
  • src/datamodel_code_generator/parser/_passes/cross_module.py
  • src/datamodel_code_generator/parser/_passes/modules.py
  • src/datamodel_code_generator/parser/_passes/plans.py
  • src/datamodel_code_generator/parser/_passes/render_prep.py
  • src/datamodel_code_generator/parser/_passes/settle.py
  • src/datamodel_code_generator/parser/_passes/structure.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The parser pass pipeline now centralizes module-name and reference-expression handling, passes run state through cross-module passes, and updates model grouping, stand-in filtering, circular-reference planning, sorting, and render preparation.

Changes: Parser Pass Coordination

Layer / File(s) Summary
Shared pass helpers and state
src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/_passes/_state.py, src/datamodel_code_generator/parser/_passes/_tables.py
Shared module protocols and reference helpers were added or updated. Module-name assignment and pass-table calls were changed.
Cross-module references and base classes
src/datamodel_code_generator/parser/_passes/cross_module.py, src/datamodel_code_generator/parser/_passes/modules.py, src/datamodel_code_generator/parser/_passes/render_prep.py
Cross-module passes use run contexts and shared reference-expression handling. Generic base-class assignment, import processing, and inherited-field reference updates were changed.
Module grouping and circular imports
src/datamodel_code_generator/parser/_passes/structure.py
Structure processing now updates module indexes in place and filters stand-ins through a shared helper. Duplicate handling, internal-module naming, and circular-import ordering were also changed.
Reference planning and render preparation
src/datamodel_code_generator/parser/_passes/plans.py, src/datamodel_code_generator/parser/_passes/settle.py, src/datamodel_code_generator/parser/_passes/render_prep.py
Circular-reference planning and model sorting were updated. Render preparation changes reference updates, default deserialization and warnings, constructor field sorting, and model collection.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested labels: breaking-change-analyzed

Merge Risk: Minimal · up to 03c43

No actionable merge-blocking issue remains established for the parser-pass refactoring. Merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the changed areas: reference rebinding, run arguments, and pass orderings in the structure, render preparation, settle, and cross-module passes. The raw summary supports this. It cover…
Docstring Coverage Passed Docstring coverage is 91.43% 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the changed areas: reference rebinding, run arguments, and pass orderings in the structure, render preparation, settle, and cross-module passes. The raw summary supports this. It covers shared set_reference_expressions and without_stand_ins helpers, CrossModuleRun replacing separate context arguments, and reordered sorting in structure, render_prep, settle, and cross_module. The title is long (135 characters, 19 words) and its wording is somewhat dense. Still, it refers to the main change and does not mislead.

Full details: Docstring Coverage

Explanation

Docstring coverage is 91.43% 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 35 functions across 9 files.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T15:04:20.377048Z 03c43fb PR opened
ℹ️ About Codex in GitHub

Your 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.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 29, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 12.2%

1 warning

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

❌ 1 regressed benchmark
✅ 51 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_load_yaml_openapi_large 34.5 ms 39.3 ms -12.2%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing dry-r34 (03c43fb) with dry-r36 (0f2e122)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit a8b63bb into main Oct 29, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the dry-r34 branch October 29, 2026 16:18
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The diff only touches private modules under parser/_passes and is a behaviour-preserving refactor. It adds a set_reference_expressions helper that replaces repeated set_reference_expression loops, using members=None wherever the old code passed same_module=False. It adds a without_stand_ins helper that replaces repeated stand-in filtering, and a ModuleNamesView protocol. It changes the cross_module pass functions (import_removed_reuse_canonicals, import_renamed_types, import_enum_member_literal_classes, apply_generic_base_class) to take the run object, wired up through late() in the pass table. It removes the internal ModuleContextFields alias and the live_models state field, and it moves _group_models_by_module and _index_module_models to writing into the state object. The rest is control-flow tidying with equivalent logic: _ModuleNames.assign, the settle sort branches, compute_internal_module_path, the root-module choice in apply_generic_base_class, record_decimal_default_warning, fix_constructor_field_ordering_of, create_shared_module_from_duplicates and resolve_circular_imports. None of this is a public CLI or Python API, a template, a default option value, a supported Python version or error reporting. The behaviour diff gate compares against the last release, so it is cumulative. Its accepted cells all concern allOf schemas whose parts admit no object, which used to become empty object models and now become root models or aliases, and their own notes attribute this to an earlier allOf change. Nothing in this diff touches allOf handling. The crash-fix cell does not change behaviour, and the both-fail cells fail before and after. So none of the default-output changes the gate shows come from this PR, and there are no breaking changes.


This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant