Skip to content

Read --intersect-allof-keywords in one place, as four named legacy rows of the intersection core - #5423

Merged
Koudai Aono (koxudaxi) merged 6 commits into
dry-a0from
dry-a2
Oct 29, 2026
Merged

Koudai Aono (koxudaxi) merged 6 commits into
dry-a0from
dry-a2

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Byte-identical refactor (A2 of the decision-home plan).

Summary by CodeRabbit

  • Compatibility
    • JSON Schema generation continues to apply legacy merge behavior in selected cases when --intersect-allof-keywords is disabled, including $ref siblings, inherited overrides, pattern constraints, allOf value forms, and null handling.
    • OpenAPI parameter schemas now follow consistent rules for merging $ref siblings.

@coderabbitai

coderabbitai Bot commented Oct 28, 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 871d4ee and 54647b0.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 5
  • docs/architecture.md
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/parser/_intersection.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • src/datamodel_code_generator/parser/openapi.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 PR centralizes allOf keyword intersection policy in shared legacy-row definitions and applies those rows across JSON Schema parsing. It updates $ref sibling merge checks in JSON Schema and OpenAPI parsing, and aligns architecture documentation and decision-home records with the policy.

Changes: AllOf intersection policy

Layer / File(s) Summary
Shared intersection policy
src/datamodel_code_generator/parser/_intersection.py, scripts/decision_homes.toml, docs/architecture.md
The shared intersection module defines keyword and legacy-row constants. intersect_keywords accepts legacy rows and returns the original row when legacy-merge-row is present. The decision records document the adapter and legacy rows.
AllOf parsing behavior
src/datamodel_code_generator/parser/jsonschema.py, scripts/decision_homes.toml
JsonSchemaParser uses legacy rows to control null handling, pattern conjunction, allOf value-site forms, inherited-field merging, and enum intersection. The decision-home allowlist records affected parser functions.
Reference-sibling merging
src/datamodel_code_generator/parser/jsonschema.py, src/datamodel_code_generator/parser/openapi.py
Both parsers use _merges_ref_siblings to determine when to merge $ref siblings with schema keywords.

Priority: Low

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

Change: Refactor

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · previous review 54647

The refactor centralizes intersection policy without an identified behavior regression. No actionable merge-blocking risk remains; normal checks should pass before merging.

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 identifies the main change: centralizing the --intersect-allof-keywords read and naming the four legacy intersection rows. It is specific and related to the pull request objective…
Docstring Coverage Passed Docstring coverage is 100.00% 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. Documentat…
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 accurately identifies the main change: centralizing the --intersect-allof-keywords read and naming the four legacy intersection rows. It is specific and related to the pull request objectives.

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 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 2 functions across 2 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

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 🔄 Running since 2026-10-28T15:53:47.522373Z 54647b0 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 28, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 33.99%

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

❌ 52 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_simple_msgspec_unset_field_rendering 270.9 ms 491.9 ms -44.93%
❌ test_perf_client_calls[sync] 24.1 ms 42 ms -42.54%
❌ test_perf_scalar_root_collapsed_builtin 126.3 ms 217.8 ms -42.02%
❌ test_perf_client_calls[async] 27 ms 46.4 ms -41.96%
❌ test_perf_false_reference_validation 164.3 ms 277.9 ms -40.88%
❌ test_perf_inherited_required_fields[partial-derived-first] 696.2 ms 1,173 ms -40.64%
❌ test_perf_ordinary_array_constraint_generation 1.2 s 1.9 s -40.46%
❌ test_perf_inherited_required_fields[required-base-first] 404.6 ms 662.6 ms -38.93%
❌ test_perf_large_models_dataclass_builtin 860 ms 1,408 ms -38.92%
❌ test_perf_local_reference_file_resolution 81 ms 132.1 ms -38.69%
❌ test_perf_large_models_typed_dict[total-false-requiredness] 698.2 ms 1,136.7 ms -38.58%
❌ test_perf_load_pyproject_config[mapping-None] 227.6 µs 370 µs -38.48%
❌ test_perf_large_models_msgspec 1.2 s 1.9 s -38.43%
❌ test_perf_large_models_typed_dict[legacy-requiredness] 702.9 ms 1,128.1 ms -37.7%
❌ test_perf_load_pyproject_config[config-None] 225.8 µs 361.4 µs -37.52%
❌ test_perf_large_models_pydantic_v2_builtin_double_quotes 882.4 ms 1,407.7 ms -37.32%
❌ test_perf_load_pyproject_config[mapping-multiple] 236.3 µs 376.6 µs -37.24%
❌ test_perf_load_pyproject_config[config-multiple] 237.5 µs 377.8 µs -37.14%
❌ test_perf_large_models_pydantic_v2_builtin 841 ms 1,330.8 ms -36.81%
❌ test_perf_inherited_required_fields[partial-base-first] 662.5 ms 1,047.7 ms -36.77%
... ... ... ... ...

ℹ️ 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 dry-a2 (32ad2d9) with dry-a0 (d2e82e8)

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 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…e before rewriting the allowlist, literal False exclusion keywords
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor and changes nothing for users by default. Every direct read of intersects_allof_keywords in the JSON Schema parser now goes through a new cached _legacy_intersection set. That set holds four named legacy rows (legacy-merge-row, legacy-lookahead-patterns, legacy-all-of-site-form, legacy-all-of-null-as-written) and contains all of them unless --intersect-allof-keywords is passed. I traced each rewritten condition under default options and each one gives the same result as before. The _null_mode flag type_excludes_member_null is still false. The ref-sibling and inherited-property merges still return the earlier merge row, because intersect_keywords returns it under legacy-merge-row. Pattern joining still uses lookaheads. The allOf site form, the null_member and FIELDLESS_SITE_KEY marking, and the array allOf path are unchanged too: the array path now calls _all_of_root_value_schema, but that function still returns None at once for arrays in legacy mode. The other edits are equivalent rewrites: repeated has_ref_with_schema_keywords checks are replaced by the existing _merges_ref_siblings helper, some literal-equality loops now use intersect_enum_values, and the row dict is built with a comprehension. The API changes are limited to private members. _intersect_parts and _all_of_value_schema are removed, and the module constant _INTERSECTED_KEYWORDS moves to _intersection.py as INTERSECTED_KEYWORDS. intersect_keywords gains an optional keyword-only legacy_rows parameter that defaults to an empty tuple. The other changes are documentation, decision-home tooling and its tests. The behaviour diff gate does show accepted cells, but it compares the PR build with the last release, so it includes earlier unreleased changes. Its notes credit those cells to an earlier PR (the allOf sites whose parts admit no object). It also flags an unrelated crash-fix cell about module import names, which confirms the gate covers changes beyond this PR. The code those accepted cells depend on is already in the removed lines with the same default behaviour, so this PR did not cause them.


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