Skip to content

Move the document reading of the JSON Schema parser into a module of its own and turn option values into arguments in one place - #5696

Merged
Koudai Aono (koxudaxi) merged 2 commits into
ci-shard-rebalance-2from
impl-batch-a
Oct 31, 2026
Merged

Koudai Aono (koxudaxi) merged 2 commits into
ci-shard-rebalance-2from
impl-batch-a

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Recommendation commands now handle configured values and repeated options more consistently, including values that cannot be represented as command-line arguments.
    • Improved handling of schema references and JSON Pointers, including pointers with slash-containing keys.
  • Documentation
    • Updated architecture documentation with current schema-loading, reference-reading, configuration, and recommendation behavior.

@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 1d06473 and e8d265e.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 14
  • docs/architecture.md
  • scripts/decision_homes.toml
  • scripts/recommender_calibrate.py
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/_option_names.py
  • src/datamodel_code_generator/_recommend/__init__.py
  • src/datamodel_code_generator/_recommend/_report.py
  • src/datamodel_code_generator/_recommend/_rules.py
  • src/datamodel_code_generator/parser/_api_reference.py
  • src/datamodel_code_generator/parser/_null_facts.py
  • src/datamodel_code_generator/parser/_schema_documents.py
  • src/datamodel_code_generator/parser/_schema_reading.py
  • src/datamodel_code_generator/parser/_schema_refs.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; 6 remain after this review.

Walkthrough

The pull request extracts schema-document and reference-processing operations into dedicated parser modules. It also centralizes option argument generation and configured-value handling across CLI and recommendation paths.

Changes: Schema Parser Operations

Layer / File(s) Summary
Document loading and resource indexing
src/datamodel_code_generator/parser/_schema_documents.py, src/datamodel_code_generator/parser/jsonschema.py, src/datamodel_code_generator/parser/_null_facts.py, docs/architecture.md, scripts/decision_homes.toml
Schema document loading, resource registration, reference rewriting, and indexing move into _schema_documents. JsonSchemaParser delegates these operations, and architecture references identify the new locations.
Source parsing and definition traversal
src/datamodel_code_generator/parser/_schema_documents.py, src/datamodel_code_generator/parser/jsonschema.py
Source iteration, loading, parsing, reserved-target lookup, and definition traversal move into _schema_documents; parser methods delegate to the extracted helpers.
JSON Pointer reading
src/datamodel_code_generator/parser/_schema_reading.py, src/datamodel_code_generator/parser/jsonschema.py, src/datamodel_code_generator/parser/_api_reference.py, docs/architecture.md
_schema_reading provides URI-fragment decoding, pointer traversal and splitting, and schema-entry classification. Parser imports and the API reference use the shared helpers.
Reference resolution and traversal
src/datamodel_code_generator/parser/_schema_refs.py, src/datamodel_code_generator/parser/jsonschema.py, docs/architecture.md
Reference reading, dynamic-reference analysis, recursive-reference resolution, and cycle traversal use module-level helpers in _schema_refs; parser methods delegate to them.

Configuration and Recommendation Values

Layer / File(s) Summary
Configuration values to CLI arguments
src/datamodel_code_generator/_option_names.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/_recommend/*, scripts/recommender_calibrate.py, scripts/decision_homes.toml, docs/architecture.md
values_arguments creates CLI arguments in input order and omits values without an expressible option. The CLI and recommendation reporting use this helper.
Configured values and recommendation merging
src/datamodel_code_generator/_option_names.py, src/datamodel_code_generator/_recommend/*, scripts/decision_homes.toml, docs/architecture.md
configured_value supplies TOML-spelled values for comparisons and validation. _merged_values combines option mappings, with later values replacing earlier values for the same field.

Priority: Low

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

Change: Refactor

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to e8d26

No merge-blocking defect was identified in the parser extraction or configuration-value consolidation. Merge after normal checks pass.

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 summarizes both primary changes: moving JSON Schema document reading into its own module and centralizing option-value conversion into arguments. It is specific and related to the ch…
Docstring Coverage Passed Docstring coverage is 85.71% 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 clearly summarizes both primary changes: moving JSON Schema document reading into its own module and centralizing option-value conversion into arguments. It is specific and related to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 85.71% 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 70 functions across 12 files. (2 skipped: 2 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 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-30T18:49:18.131896Z e8d265e 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 50.67%

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

⚠️ 52 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 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[async] 20.2 ms 47 ms -57.09%
❌ test_perf_simple_pydantic_v2_field_construction 5.8 ms 13.3 ms -56.01%
❌ test_perf_client_calls[sync] 19.1 ms 43.3 ms -55.85%
❌ test_perf_large_models_pydantic_v2 1.8 s 4.1 s -55.22%
❌ test_perf_load_pyproject_config[config-multiple] 174.7 µs 386.4 µs -54.79%
❌ test_perf_complex_refs 1 s 2.3 s -54.73%
❌ test_perf_load_pyproject_config[config-None] 168.4 µs 368.2 µs -54.25%
❌ test_perf_deep_nested 2.8 s 6 s -54.11%
❌ test_perf_duplicate_names 532.8 ms 1,150.6 ms -53.69%
❌ test_perf_simple_msgspec_unset_field_rendering 256.1 ms 550 ms -53.44%
❌ test_perf_local_reference_file_resolution 66.3 ms 142.2 ms -53.36%
❌ test_perf_load_pyproject_config[mapping-None] 175.1 µs 372.8 µs -53.03%
❌ test_perf_scalar_root_collapsed_builtin 104.2 ms 220.5 ms -52.74%
❌ test_perf_all_options_enabled 3.1 s 6.5 s -52.6%
❌ test_perf_large_models_typed_dict[legacy-requiredness] 618.6 ms 1,303.5 ms -52.54%
❌ test_perf_large_models_pydantic_v2_builtin_double_quotes 712.2 ms 1,498.7 ms -52.48%
❌ test_perf_inherited_required_fields[required-base-first] 338.5 ms 710 ms -52.32%
❌ test_perf_load_pyproject_config[mapping-multiple] 183 µs 383.8 µs -52.31%
❌ test_perf_large_models_pydantic_v2_builtin 686.6 ms 1,437.3 ms -52.23%
❌ test_perf_pydantic_field_name_resolution 1.3 ms 2.7 ms -52.23%
... ... ... ... ...

ℹ️ 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-batch-a (e8d265e) with ci-shard-rebalance-2 (1d06473)

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 846484d into main Oct 31, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-batch-a branch October 31, 2026 00:29
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The diff is a behaviour-preserving internal refactor. Document-reading logic moves verbatim from parser/jsonschema.py into a new parser/_schema_documents.py module, the JSON pointer walk helpers move into parser/_schema_reading.py, and several reference helpers move into parser/_schema_refs.py. JsonSchemaParser keeps its delegating methods such as parse_ref, parse_id and the private load and iterate hooks, and parser.jsonschema still imports and re-exports the public names get_model_by_path, split_json_pointer and unescape_json_pointer_segment. Only underscore-prefixed private methods and imports were removed. The recommender and CLI changes consolidate repeated code into values_arguments, configured_value and _merged_values, which produce the same arguments in the same order with the same later-wins merge. The remaining changes are documentation and decision_homes.toml tooling config. The behaviour diff gate lists accepted cells where an allOf whose parts admit no object now becomes a RootModel or alias instead of an empty object model, but the gate compares against the last release and so includes earlier unreleased PRs. Its notes point to an earlier allOf intersection change, and nothing in this diff touches allOf handling, so those output changes do not come from this PR. No CLI options, public API, templates, defaults, Python version support or error handling change in this diff.


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