Skip to content

Move the render preparation, import and finish passes and the pass tables into their own modules - #5270

Merged
Koudai Aono (koxudaxi) merged 1 commit into
fix-5227-ref-cyclefrom
ph3d-pass-modules
Oct 24, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
fix-5227-ref-cyclefrom
ph3d-pass-modules

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Reorganized parser processing into clearly defined stages, with no intended changes to generated output or runtime behavior.
    • Updated architecture documentation to reflect the processing flow and stage boundaries.
  • Chores
    • Updated internal checks and tests to match the reorganized processing pipeline.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 24a8fb2 and 41375977ced7ad14feb7ecf9ff8230dc72f3072b.

⛔ Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
📒 Files selected for processing: 22
  • docs/architecture.md
  • scripts/check_architecture_boundaries.py
  • scripts/check_pass_pipeline.py
  • scripts/generation_store_allowlist.toml
  • src/datamodel_code_generator/model/_decisions/assignment.py
  • src/datamodel_code_generator/parser/_imports_plan.py
  • 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/decide.py
  • src/datamodel_code_generator/parser/_passes/imports.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
  • src/datamodel_code_generator/parser/_pipeline.py
  • src/datamodel_code_generator/parser/base.py
  • tests/main/test_main_general.py
  • tests/parser/test_base.py
  • tests/parser/test_model_construction_capabilities.py

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

📝 Walkthrough

The parser pipeline is moved into declarative pass tables, with run-state contracts and pass implementations in dedicated modules. The changes also update pipeline checks, architecture documentation, and tests to use the pass modules.

Changes: Parser pipeline extraction

Layer / File(s) Summary
Run-state contracts and pipeline interfaces
src/datamodel_code_generator/parser/_passes/_state.py, src/datamodel_code_generator/parser/_pipeline.py, src/datamodel_code_generator/parser/_passes/_tables.py, scripts/check_architecture_boundaries.py, docs/architecture.md
Run-state protocols and adapters are added, and pipeline interfaces and permitted pass imports are updated.
Pipeline ordering and module processing
src/datamodel_code_generator/parser/_passes/_tables.py, src/datamodel_code_generator/parser/_passes/settle.py, src/datamodel_code_generator/parser/_passes/modules.py, src/datamodel_code_generator/parser/_passes/cross_module.py, src/datamodel_code_generator/parser/_passes/decide.py, scripts/check_pass_pipeline.py, docs/architecture.md
Declarative tables order parsing through rendering. Pass modules add parsing, per-module and cross-module processing, and decision execution.
Model render preparation
src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/_passes/render_prep.py, src/datamodel_code_generator/model/_decisions/assignment.py, tests/parser/test_base.py, tests/parser/test_model_construction_capabilities.py, tests/main/test_main_general.py, docs/architecture.md
Render-preparation functions cover model defaults, field ordering, forward references, aliases, and render plans. Tests and documentation refer to these pass functions.
Import finalization and rendering
src/datamodel_code_generator/parser/_passes/imports.py, src/datamodel_code_generator/parser/_imports_plan.py, scripts/generation_store_allowlist.toml, docs/architecture.md
Import passes add name checks, import planning, finalization, placement recording, and module rendering. The allowlist and pass references are updated.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Parser
  participant PipelineTables
  participant ModulePasses
  participant RenderPreparation
  participant ImportAndRenderPasses
  Parser->>PipelineTables: Run PIPELINE from parse()
  PipelineTables->>ModulePasses: Process modules and cross-module work
  PipelineTables->>RenderPreparation: Prepare and finalize model rendering
  PipelineTables->>ImportAndRenderPasses: Plan imports and render module outputs
Loading

Possibly related issues

  • Issue 5130: The issue concerns field preparation during rendering, which this PR relocates to render_prep.py; the summaries do not indicate a change to custom subclass rendering behavior.

Possibly related PRs

Merge Risk: ⚪ Minimal · up to 41375

This is a code-organization refactor that moves parser passes and pipeline tables into separate modules, with documentation and tests updated to match. No runtime behavior change or user-facing risk was identified. The remaining items are minor unused-code cleanups.

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 accurately and clearly summarizes the primary change: moving render preparation, import, finish passes, and pipeline tables into separate modules.
Docstring Coverage Passed Docstring coverage is 95.06% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 243 functions across 19 files. (2 skipped: …
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: Docstring Coverage

Explanation

Docstring coverage is 95.06% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 243 functions across 19 files. (2 skipped: 2 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

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 23, 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-23T22:15:28.298915Z 4137597 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 23, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 25.61%

2 warnings

⚠️ 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

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

❌ 50 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_recommend_options_full_kubernetes_style 15.6 s 27.3 s -42.87%
❌ test_perf_target_render[fastapi-large] 5 s 7.6 s -34.43%
❌ test_perf_load_pyproject_config[mapping-None] 253.2 µs 372.8 µs -32.08%
❌ test_perf_target_render[client-large] 6.1 s 9 s -32.01%
❌ test_perf_load_pyproject_config[config-multiple] 262.9 µs 385.9 µs -31.89%
❌ test_perf_load_pyproject_config[config-None] 251.7 µs 369.5 µs -31.88%
❌ test_perf_load_pyproject_config[mapping-multiple] 263.8 µs 380.8 µs -30.72%
❌ test_perf_client_calls[async] 33 ms 47.3 ms -30.25%
❌ test_perf_false_reference_validation 268.9 ms 385 ms -30.14%
❌ test_perf_simple_msgspec_unset_field_rendering 122.6 ms 175.1 ms -29.98%
❌ test_perf_client_calls[sync] 29.8 ms 42.4 ms -29.85%
❌ test_perf_deep_nested 4.7 s 6.7 s -29.65%
❌ test_perf_all_options_enabled 5.4 s 7.6 s -28.78%
❌ test_perf_complex_refs 1.8 s 2.6 s -28.67%
❌ test_perf_pattern_properties_adapter_reuse 3 ms 4.1 ms -28.16%
❌ test_perf_stripe_style_pydantic_v2 1.8 s 2.5 s -27.31%
❌ test_perf_aws_style_openapi_pydantic_v2 1.8 s 2.5 s -26.98%
❌ test_perf_scalar_root_collapsed_builtin 174.4 ms 237.6 ms -26.62%
❌ test_perf_extreme_large_schema 13.3 s 18.1 s -26.35%
❌ test_perf_local_reference_file_resolution 133.6 ms 181.1 ms -26.23%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

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


Comparing ph3d-pass-modules (fae86f9) with fix-5227-ref-cycle (24a8fb2)

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 23, 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 ebda3d3 into main Oct 24, 2026
131 of 132 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the ph3d-pass-modules branch October 24, 2026 01:42
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor. It moves the private pass methods of Parser (name-mangled double-underscore methods such as the constructor field ordering, type alias updates, import finalization, msgspec decoding warnings and the render step) and the class-level pipeline tables out of parser/base.py into new private modules under parser/_passes: _tables.py, render_prep.py, imports.py and decide.py. The run state classes move into _passes/_state.py. The public names parser/base.py used to export are re-exported there: SPECIAL_PATH_FORMAT, get_special_path, PydanticFloors, pydantic_floors_recorded, override_required_field, the modules and plans references, and private shims for moved helpers. The overridable hooks _build_module_structure, _process_single_module and _finalize_modules, and the use of Parser._build_code_formatter and Result, behave as before. Warnings now go through warn_as_parser_base with the same UserWarning or DefaultValueTypeWarning categories and the same messages, so module filters on parser.base still match them; the new tests confirm this. The rest of the PR is doc updates, allowlist and script path updates, and tests moved from name-mangled private methods to the new module functions. No CLI option, public API, generated output, template, default, Python version support or error message changes.


This analysis was produced by the release draft workflow

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.

2 participants