Skip to content

Move the L5 preparation and simple processing passes into their own modules - #5207

Merged
Koudai Aono (koxudaxi) merged 1 commit into
review-fixes-2from
ph3c1-pass-modules
Oct 23, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
review-fixes-2from
ph3c1-pass-modules

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Updated model-generation processing across inheritance, defaults, field naming, type overrides, and model ordering. Existing processing order and conditions are preserved.
  • Documentation
    • Updated architecture documentation to reflect current pass names, responsibilities, and dependencies.

@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 42c3e6c292bae8e4c9fab001a21794b3f0e461c8 and b03f9f3ff8c29401d57471964632cb920ea5dd6b.

⛔ 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/generation_store_allowlist.toml
  • scripts/normalize_pass_moves.py
  • src/datamodel_code_generator/model/_decisions/enum_kind.py
  • src/datamodel_code_generator/model/_decisions/literal_default.py
  • src/datamodel_code_generator/parser/_passes/_keys.py
  • src/datamodel_code_generator/parser/_passes/_shared.py
  • src/datamodel_code_generator/parser/_passes/modules.py
  • src/datamodel_code_generator/parser/base.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • tests/assert_helper_allowlists.py
  • tests/parser/test_base.py
💤 Files with no reviewable changes: 1
  • tests/assert_helper_allowlists.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’s module-level passes and shared helpers move into parser/_passes. parser/base.py delegates to the extracted functions. Architecture references, boundary checks, allowlists, and tests are updated to reflect the new pass locations.

Changes: Parser module-pass extraction

Layer / File(s) Summary
Shared pass helpers
src/datamodel_code_generator/parser/_passes/_keys.py, src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/base.py
Shared helpers now cover data-type copying, imports, renamed types, references, and constructor ordering. Related parser-local helper implementations are removed or delegated.
Module ordering and transformations
src/datamodel_code_generator/parser/_passes/modules.py, src/datamodel_code_generator/parser/base.py
The module pass module adds model ordering and transformations for defaults, enums, unique-item lists, and unused-model tracking.
Name and type overrides
src/datamodel_code_generator/parser/_passes/modules.py, src/datamodel_code_generator/parser/base.py
The module pass module adds field-name collision handling, type overrides, and root-model dictionary-key rewriting.
Parser delegation and boundary updates
src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/parser/jsonschema.py, scripts/*, tests/*, docs/architecture.md, src/datamodel_code_generator/model/_decisions/*
The parser delegates to the extracted passes. Tests, pass-move tooling, architecture checks, allowlists, and pass references are updated.

Priority: ⬇️ Low

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

Change: Refactor

Possibly related PRs

Merge Risk: ⚪ Minimal · up to b03f9

This is a refactor that relocates parser passes into dedicated modules with the parser delegating to them. No concrete behavior change or defect was found, so merge risk is minimal.

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 main change: moving L5 preparation and simple processing passes into separate modules.
Docstring Coverage Passed Docstring coverage is 81.38% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 145 functions across 9 files. (3 skipped: 2…
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 81.38% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 145 functions across 9 files. (3 skipped: 2 unsupported, 1 too large.)

✨ 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-23T12:16:51.477390Z b03f9f3 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 not alter performance

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

✅ 50 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing ph3c1-pass-modules (2411ce4) with review-fixes-2 (494db72)

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 cb8722d into main Oct 23, 2026
131 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the ph3c1-pass-modules branch October 23, 2026 16:07
@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 L5 module passes, which were private name-mangled Parser methods such as replace_unique_list_to_set, extract_inherited_enum, set_default_enum_member, sort_models, change_field_name, type_const_narrowed_values, set_one_literal_on_default, rename_fields_hiding_types, apply_field_type_overrides, type_dict_keys_by_root_types and apply_base_class_type_overrides. It also moves their underscore-prefixed helpers out of parser/base.py and into a new parser/_passes/modules.py module and into parser/_passes/_shared.py. The function bodies are carried over almost unchanged: self becomes a parser parameter typed by a ModulesHost Protocol. The pipeline table in parser/base.py now calls the new functions in the same order. _DERIVED_FROM_KEY moves to _passes/_keys.py, and jsonschema.py imports it from there. The other changes are docs, an allowlist, an architecture-check script and test updates. No CLI options, Python API parameters, templates, defaults or Python version support change, and nothing in the diff changes generated output or error handling. The only removed names without an underscore are internal type aliases for keep-model-order sorting in parser/base.py, such as ModelName and ModelDeps. They are not part of the documented public API, so this PR is not a user-facing breaking change.


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.

1 participant