Repository navigation
Remove the duplicated code of the first part of parser/jsonschema.py: one type intersection core, one tuple position path and dynamic anchor components from _scc - #5511
Conversation
… experimental registries through one shared Markdown renderer
… instead of the seven flags written out at each site
…and problem builder
…on, one literal container renderer and smaller copies
… table, one protobuf declaration walk, Avro defaults read from the logical type ladder and smaller copies
…ent renderer's forwarding wrappers
…collisions and plan_target
… one type intersection core, one tuple position path, dynamic anchor components from _scc and smaller copies
# Conflicts: # src/datamodel_code_generator/_parser_context.py
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared type and intersection handling src/datamodel_code_generator/parser/_intersection.py, src/datamodel_code_generator/parser/jsonschema.py, tests/parser/test_jsonschema.py, tests/assert_helper_allowlists.py |
The parser exposes shared type and intersection helpers and uses them in schema merging and constraint processing. The test imports and coverage snapshot no longer include two private helper checks. |
Reference traversal and lookup src/datamodel_code_generator/parser/jsonschema.py |
Decoded JSON Pointer traversal supports missing-value checks. Reference lookup, external-reference key normalization, and reference-fact caching use shared helpers. |
Schema constraints and array handling src/datamodel_code_generator/parser/jsonschema.py |
Constraint extraction and array-position selection use shared helpers. The parser also updates exclusive-bound conversion, property-count handling, and tuple inference. |
Inherited fields and read/write variants src/datamodel_code_generator/parser/jsonschema.py |
Inherited-field handling and read/write fact aggregation are consolidated. Additional-property types are stored through a shared helper for model variants. |
Dynamic-anchor reachability src/datamodel_code_generator/parser/jsonschema.py, scripts/decision_homes.toml |
Dynamic-reference analysis builds a reachable-node graph, computes strongly connected components, and caches anchor usage. The H20 adapter list includes _dynamic_anchors_used. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Refactor
Possibly related issues
- Issue 5453 — The changes consolidate type intersection used during JSON Schema merging, which is related to the issue’s nested-property intersection behavior.
- Issue 5380 — The changes update shared intersection and
$refsibling analysis in the parser area identified by this issue.
Possibly related PRs
- datamodel-code-generator/datamodel-code-generator#5423: Both PRs centralize JSON Schema intersection behavior in
parser/_intersection.py. - datamodel-code-generator/datamodel-code-generator#5379: Both PRs address JSON Schema type-list intersection and numeric type compatibility.
- datamodel-code-generator/datamodel-code-generator#5494: This PR uses the strongly connected components utility for dynamic-reference reachability.
Merge Risk: 
Minimal · up to 43e51
-
The parser consolidation has no identified merge-blocking issue and appears mergeable subject to normal checks.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title accurately describes the main changes: deduplicating type intersection logic, tuple position paths, and dynamic anchor handling. It is lengthy, but it remains specific and related to the changeset.
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 4 functions across 1 files. (2 skipped: 1 unsupported, 1 too large.)
-
Finishing Touches: 💡 1
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
🛠️ Fix failing CI checks: 💡
-
- 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.
Comment @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
Merging this PR will degrade performance by 31.04%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is an internal refactor of the JSON Schema parser that keeps behaviour the same. In the private parser/_intersection.py module, _types and _intersect_types are renamed to declared_types and intersect_types and a common_types helper is added. In jsonschema.py, private helpers that duplicated these are removed and replaced: _json_schema_types, _intersect_json_schema_types, _admits_arrays, _json_literal_may_accept_container, _json_schema_type_may_accept_container, _get_model_by_path_or_missing and _get_data_type_constraint_kwargs. Private parser methods are folded into shared ones: _get_schemas_before_false, _tail_schema, _get_explicit_fixed_positional_items, _get_fixed_length_prefix_tuple_items, _fallback_array_item_data_types and _finalize_required_inherited_field. The hand-written Tarjan SCC is replaced with the shared strongly_connected_components helper. Several match blocks and boolean chains are collapsed into equivalent expressions: the exclusive bound validator, the property-count constraints, propertyNames checks, read/write variant facts, external ref mapping keys and constraint value collection. Every removed or renamed symbol is underscore-private. The constraint_fields class attribute still holds the same set. No CLI option, public Python API, template or Python version support changes. The only test changes delete assertions on the removed private helpers, and no expected generated-output fixtures change, so the generated code is the same as at the parent commit. The behaviour-gate rows marked accepted compare against the last release and describe an earlier allOf change; their notes name a different PR and none of their fixtures change here. The other rows are both-fail or crash-fix, which do not change behaviour. This analysis was produced by the release draft workflow |
|
🎉 Released in 0.88.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit