Skip to content

Move the settle and structure passes into their own modules - #5196

Merged
Koudai Aono (koxudaxi) merged 1 commit into
wave7-review-fixesfrom
ph3a-pass-modules
Oct 23, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
wave7-review-fixesfrom
ph3a-pass-modules

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Improvements
    • Improved dependency ordering for generated models, including runtime-validation references.
    • Refined model grouping, deduplication, reuse, and circular-import handling when generating modules.
  • Documentation
    • Updated architecture guidance to reflect current component responsibilities and helper locations.

@coderabbitai

coderabbitai Bot commented Oct 23, 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 60115dc and 17fdd23.

⛔ Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
📒 Files selected for processing: 13
  • docs/architecture.md
  • scripts/check_architecture_boundaries.py
  • scripts/normalize_pass_moves.py
  • src/datamodel_code_generator/__init__.py
  • src/datamodel_code_generator/parser/_passes/_shared.py
  • src/datamodel_code_generator/parser/_passes/_state.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/parser/test_base.py
  • tests/parser/test_builtin_formatter_contract.py
  • tests/parser/test_imports.py

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

📝 Walkthrough

The parser’s settle and structure operations now live in dedicated pass modules, with shared helpers and run-state types in _passes/_shared.py and _passes/_state.py. parser/base.py delegates to these functions. The change also updates pass tracing, pass-move comparison tooling, architecture documentation, and boundary checks.

Changes: Parser pass extraction

Layer / File(s) Summary
Shared pass contracts and helpers
src/datamodel_code_generator/parser/_passes/_state.py, src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/base.py
_state.py defines run-state types and protocols. _shared.py adds model ordering, reference, reuse, and recursion helpers. parser/base.py imports or aliases these definitions.
Settle pass extraction
src/datamodel_code_generator/parser/_passes/settle.py, src/datamodel_code_generator/parser/base.py
settle.py implements model ordering, diagnostics, name settlement, parse configuration, and source-reference recording. parser/base.py removes the corresponding local implementations and delegates settle operations.
Structure pass extraction
src/datamodel_code_generator/parser/_passes/structure.py, src/datamodel_code_generator/parser/base.py, tests/parser/*
structure.py implements module grouping, model reuse and deduplication, circular-import resolution, and formatter setup. parser/base.py removes the local implementations, and parser tests call module-level functions.
Delegation and supporting checks
src/datamodel_code_generator/parser/_pipeline.py, src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/__init__.py, scripts/*, docs/architecture.md
parser/base.py delegates pipeline operations to pass functions using late-bound lookup. Pass tracing, move-comparison tooling, architecture documentation, and import-boundary checks are updated.

Priority: ⬇️ Low

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

Change: Refactor

Merge Risk: ⚪ Minimal · up to 17fdd

This change reorganizes parser internals without a demonstrated behavior change, and no merge-blocking issue was found.

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 clearly and concisely describes the primary change: moving the settle and structure passes into separate modules.
Docstring Coverage Passed Docstring coverage is 80.75% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 161 functions across 12 files. (1 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 80.75% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 161 functions across 12 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

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-23T08:46:49.251248Z 1302284 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

Comment thread scripts/normalize_pass_moves.py Fixed
Comment thread scripts/normalize_pass_moves.py Fixed
@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 19.91%

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

⚡ 45 improved benchmarks
✅ 5 untouched benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_client_calls[sync] 32.2 ms 23.7 ms +35.88%
⚡ test_perf_client_calls[async] 35.6 ms 26.9 ms +32.14%
⚡ test_perf_recommend_options_full_kubernetes_style 18.9 s 14.8 s +27.38%
⚡ test_perf_ordinary_array_constraint_generation 2.2 s 1.7 s +26.71%
⚡ test_perf_scalar_root_collapsed_builtin 185 ms 147.3 ms +25.59%
⚡ test_perf_large_models_single_module_stdout 1.5 s 1.2 s +25.42%
⚡ test_perf_inherited_required_fields[partial-base-first] 1,066.5 ms 851 ms +25.32%
⚡ test_perf_inherited_required_fields[partial-derived-first] 1,007.6 ms 805.1 ms +25.15%
⚡ test_perf_openapi_large_pydantic_v2_builtin 1.3 s 1 s +24.39%
⚡ test_perf_large_models_pydantic_v2_builtin 1.3 s 1.1 s +23.46%
⚡ test_perf_large_models_typed_dict[legacy-requiredness] 1,127.3 ms 913.6 ms +23.39%
⚡ test_perf_inherited_required_fields[required-base-first] 706.7 ms 575.1 ms +22.88%
⚡ test_perf_large_models_pydantic_v2_noformat 1.3 s 1.1 s +22.68%
⚡ test_perf_large_models_typed_dict[total-false-requiredness] 1,117 ms 913.4 ms +22.29%
⚡ test_perf_local_reference_file_resolution 141 ms 115.7 ms +21.81%
⚡ test_perf_large_models_pydantic_v2_builtin_double_quotes 1.4 s 1.1 s +21.53%
⚡ test_perf_inherited_required_fields[required-derived-first] 654.3 ms 539.5 ms +21.28%
⚡ test_perf_graphql_style_pydantic_v2 770.6 ms 640.1 ms +20.4%
⚡ test_perf_load_pyproject_config[mapping-multiple] 281.4 µs 235.8 µs +19.33%
⚡ test_perf_openapi_large 2.9 s 2.4 s +19.25%
... ... ... ... ...

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

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ph3a-pass-modules (17fdd23) with wave7-review-fixes (60115dc)

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) changed the base branch from fix-4932-validator-quotes to wave7-review-fixes October 23, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants