Skip to content

Drop the private re-exports of the parser base and their dead branches - #7322

Merged
Koudai Aono (koxudaxi) merged 5 commits into
mainfrom
b7-dead-branches
Nov 21, 2026
Merged

Koudai Aono (koxudaxi) merged 5 commits into
mainfrom
b7-dead-branches

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Corrected generated models for inherited JSON Schema properties, including overrides declared before their parent models.
    • Preserved field defaults, required status, nullability, list types, constraints, descriptions, and serialization aliases across inherited overrides.
    • Improved handling of request and response variants and fields not explicitly declared in the schema.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T21:02:57.766866Z e3d1da2 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.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Inherited-field resolution now uses modifier objects directly. The pull request adds deferred-override regression tests and changes allOf member handling and Decimal recipe checks.

Changes: Deferred Inherited-Field Overrides

Layer / File(s) Summary
Inherited modifier resolution
src/datamodel_code_generator/parser/_field_copies.py, src/datamodel_code_generator/parser/_passes/_shared.py, scripts/generation_store_allowlist.toml, scripts/host_private_access_baseline.toml
Inherited-field helpers now require _InheritedTypeModifiers and use its values for nullability and list-wrapper handling. The allowlist count and host-private-access baseline are updated.
Parser helper surface and tests
src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/parser/_field_copies.py, tests/parser/test_base.py, tests/assert_helper_allowlists.py
parser.base no longer re-exports the listed helpers and keys. Related private-import allowances and helper tests are removed.
Deferred override regression coverage
tests/main/jsonschema/*, tests/data/expected/main/jsonschema/deferred_inherited_overrides/*, tests/main/test_payload_validation.refs
Tests and generated references cover deferred overrides, defaults, list constants, constrained fields, required fields, and serialization aliases.

allOf Member Handling

Layer / File(s) Summary
allOf fallback handling
src/datamodel_code_generator/parser/_object_maps.py
The flattening path now appends all allOf members that do not match the existing False or True cases.

Decimal Recipe Assertion

Layer / File(s) Summary
Decimal recipe type assertion
src/datamodel_code_generator/parser/_passes/_shared.py
The runtime comparison and skip for non-Decimal recipes are replaced with a static type assertion.

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

Change: Refactor

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to e3d1d

This change removes private parser re-exports and dead branches and adds regression tests for deferred inherited-field overrides. No concrete defect was identified, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the removal of private re-exports from parser/base.py and the dead branches that depended on them. The raw summary confirms that base.py no longer re-exports the defer…
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 main change: the removal of private re-exports from parser/base.py and the dead branches that depended on them. The raw summary confirms that base.py no longer re-exports the deferred-inheritance helpers and keys, and that _field_copies.py and _shared.py drop dead branches. The title is specific and matches the changeset, and it is 12 words, slightly long but readable.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f937499 and e3d1da2.

Files ignored due to path filters: 7

  • docs/data/migration/unreleased/b7-dead-branches.toml is excluded by none and included by none
  • tests/data/expected/main/payload_validation/generated_models_decide_value_neighbours_like_the_schema[pydantic_v2_jsonschema_~68de0e2b.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/jsonschema/deferred_inherited_overrides/child_before_parent.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/deferred_inherited_overrides/list_const_restated.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/deferred_inherited_overrides/request_response_override.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/deferred_inherited_overrides/required_name_without_schema.json is excluded by !tests/data/**/*.json and included by none
  • tests/data/jsonschema/deferred_inherited_overrides/required_only_alias.json is excluded by !tests/data/**/*.json and included by none
Files selected for processing: 17

  • scripts/generation_store_allowlist.toml
  • scripts/host_private_access_baseline.toml
  • src/datamodel_code_generator/parser/_field_copies.py
  • src/datamodel_code_generator/parser/_object_maps.py
  • src/datamodel_code_generator/parser/_passes/_shared.py
  • src/datamodel_code_generator/parser/base.py
  • tests/assert_helper_allowlists.py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/default_values_beside_a_required_name_no_schema_declares.py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/deferred_override_of_a_parent_defined_later[default].py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/deferred_override_of_a_parent_defined_later[default_values].py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/list_restated_over_an_inherited_list_const.py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/request_response_variant_keeps_a_constrained_override.py
  • tests/data/expected/main/jsonschema/deferred_inherited_overrides/required_only_name_keeps_the_serialization_alias_of_the_child.py
  • tests/main/jsonschema/test_deferred_inherited_overrides.py
  • tests/main/jsonschema/test_deferred_inherited_overrides.refs
  • tests/main/test_payload_validation.refs
  • tests/parser/test_base.py
Files with no reviewable changes: 4

  • scripts/host_private_access_baseline.toml
  • src/datamodel_code_generator/parser/base.py
  • tests/assert_helper_allowlists.py
  • tests/parser/test_base.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.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 15.19%

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 improved benchmark
✅ 52 untouched benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_load_yaml_openapi_large 30.3 ms 26.3 ms +15.19%

Tip

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


Comparing b7-dead-branches (e3d1da2) with main (f937499)

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 Nov 21, 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 e1cdc79 into main Nov 21, 2026
133 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the b7-dead-branches branch November 21, 2026 21:33
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor plus test-harness changes. In parser/_field_copies.py, the private helpers now accept only _InheritedTypeModifiers and no longer handle a raw DataType for the deferred inherited type, a branch that was never reached. The private _merge_data_type_modifiers function loses its unused preserve_container_shape and preserve_optional keyword parameters. The DataType case is also removed from _detach_deferred_inherited_field_parents. A pragma-guarded continue is replaced by assert_type, which only matters to type checkers and does nothing at runtime. A JsonSchemaObject match case becomes a wildcard. In parser/base.py, the underscore-prefixed re-exports _get_inherited_type_modifiers, _merge_data_type_modifiers, _DEFERRED_INHERITED_CLASS_KEY, _DEFERRED_INHERITED_FIELD_KEY, _DEFERRED_INHERITED_TYPE_KEY and _RAW_SCHEMA_DEFAULT_KEY are removed. These are private names, not public API, and the analysis context lists no public Python name changes. The remaining changes swap unit tests that imported those private names for end-to-end CLI tests with new fixtures and expected outputs, and update allowlists and baselines. The migration note classifies the change as harness-only and says the package writes the same output. Every cell in the behaviour diff gate is both-fail, so no default output changes. No CLI options, templates, defaults, Python version support or error handling are affected.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Released in 0.100.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