Skip to content

Move the schema reading helpers the JSON Schema parser concerns share into a module of their own - #5639

Merged
Koudai Aono (koxudaxi) merged 1 commit into
impl-c06from
impl-map6
Oct 30, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
impl-c06from
impl-map6

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Improved the organization of JSON Schema parsing and validation, including handling for object maps, patterns, conditional properties, and schema constraints. Existing parsing behavior is unchanged.
  • Documentation
    • Updated architecture guidance to reflect shared schema-reading responsibilities and clarify parser dependencies.

@coderabbitai

coderabbitai Bot commented Oct 30, 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 a5184a7 and 45474a6.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 7
  • docs/architecture.md
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/parser/_null_facts.py
  • src/datamodel_code_generator/parser/_object_maps.py
  • src/datamodel_code_generator/parser/_schema_reading.py
  • src/datamodel_code_generator/parser/_schema_validators.py
  • src/datamodel_code_generator/parser/jsonschema.py

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

Walkthrough

The parser’s schema-reading, schema-validation, and object-map helpers move into dedicated modules. jsonschema.py imports or delegates to those helpers. Architecture documentation and decision-home configuration now refer to the new helper locations.

Changes: JSON Schema helper extraction

Layer / File(s) Summary
Shared schema-reading helpers
src/datamodel_code_generator/parser/_schema_reading.py, src/datamodel_code_generator/parser/jsonschema.py, src/datamodel_code_generator/parser/_null_facts.py, scripts/decision_homes.toml, docs/architecture.md
Shared schema-reading helpers move into _schema_reading.py. jsonschema.py, the decision-home configuration, and documentation refer to the extracted helpers.
Schema-validation helpers
src/datamodel_code_generator/parser/_schema_validators.py, src/datamodel_code_generator/parser/jsonschema.py, scripts/decision_homes.toml, docs/architecture.md
Schema implication, conditional-property, and pattern-validation helpers move into _schema_validators.py. Parser methods delegate to them, and SchemaValidatorsHost declares parser interfaces used by the helper logic.
Object-map parsing helpers
src/datamodel_code_generator/parser/_object_maps.py, src/datamodel_code_generator/parser/jsonschema.py, docs/architecture.md
Object-map schema handling moves into _object_maps.py. The parser delegates extra-field lookup, root-field creation, key typing, and map-type union operations to the extracted helpers.

Priority: Low

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

Change: Refactor

Possibly related PRs

Merge Risk: Minimal · up to 45474

No actionable merge-blocking issue is identified. The helper extraction appears mergeable subject to normal checks.

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 says the PR moves schema-reading helpers shared by the JSON Schema parser into their own module. The changeset matches this. It adds parser/_schema_reading.py as the shared home for these he…
Docstring Coverage Passed Docstring coverage is 92.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. Documentati…
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 says the PR moves schema-reading helpers shared by the JSON Schema parser into their own module. The changeset matches this. It adds parser/_schema_reading.py as the shared home for these helpers. It removes many helpers from jsonschema.py, and the docs and H03 config point to the new module. The title is specific and describes the main change. It does not describe the secondary work on _schema_validators.py and _object_maps.py, which is expected.

Full details: Docstring Coverage

Explanation

Docstring coverage is 92.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 25 functions across 4 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 30, 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-30T07:45:52.350427Z 45474a6 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 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 49.9%

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_client_calls[sync] 18.7 ms 43.4 ms -56.99%
❌ test_perf_client_calls[async] 20.6 ms 47.2 ms -56.29%
❌ test_perf_duplicate_names 515.1 ms 1,145.8 ms -55.04%
❌ test_perf_simple_msgspec_unset_field_rendering 243.5 ms 541.5 ms -55.03%
❌ test_perf_large_models_pydantic_v2 1.8 s 4.1 s -54.79%
❌ test_perf_large_models_dataclass_builtin 661.8 ms 1,441.1 ms -54.08%
❌ test_perf_all_options_enabled 3 s 6.5 s -53.85%
❌ test_perf_multiple_files_input 1.9 s 4.2 s -53.83%
❌ test_perf_complex_refs 1 s 2.3 s -53.67%
❌ test_perf_extreme_large_schema 8.3 s 17.9 s -53.43%
❌ test_perf_openapi_large 1.6 s 3.4 s -53.3%
❌ test_perf_deep_nested 2.8 s 6 s -52.88%
❌ test_perf_graphql_style_pydantic_v2 433.1 ms 918.5 ms -52.85%
❌ test_perf_stripe_style_pydantic_v2 1.1 s 2.2 s -52.15%
❌ test_perf_false_reference_validation 132.6 ms 276 ms -51.96%
❌ test_perf_large_models_single_module_stdout 771.6 ms 1,605 ms -51.93%
❌ test_perf_local_reference_file_resolution 64.2 ms 133.1 ms -51.81%
❌ test_perf_load_pyproject_config[mapping-multiple] 185 µs 382.8 µs -51.67%
❌ test_perf_load_pyproject_config[mapping-None] 180.4 µs 372.6 µs -51.58%
❌ test_perf_kubernetes_style_pydantic_v2 1.4 s 2.9 s -51.51%
... ... ... ... ...

ℹ️ 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 impl-map6 (45474a6) with impl-c06 (a5184a7)

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 30, 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 02500f8 into main Oct 30, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-map6 branch October 30, 2026 08:10
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The diff is an internal refactor that moves code between modules: module-level helpers of parser/jsonschema.py move into a new parser/_schema_reading.py module, and several JsonSchemaParser method bodies move into functions in parser/_object_maps.py and parser/_schema_validators.py; each moved body matches the deleted original apart from renaming self to parser, so generated output cannot change. The only removals are private: the JsonSchemaParser methods _pattern_checks_declared_key, _get_additional_properties_root_field and _object_map_type_union, plus underscore-prefixed module helpers, while the public re-exports INTERSECTED_KEYWORDS, bounds_admit_no_value and intersect_keywords are explicitly kept. The other files are docs and the internal decision_homes.toml config, with no changes to CLI options, templates, error handling or Python version support. The behaviour gate does list accepted cells for allOf schemas whose parts admit no object, which now generate RootModel or alias types, but the gate compares against the last release and its note names a different cause, while this diff copies the allOf intersection helpers over unchanged, so those changes come from other work and not from this PR.


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.

2 participants