Skip to content

Decide a branch's object exclusion by one predicate - #6776

Merged
Koudai Aono (koxudaxi) merged 1 commit into
refactor-mapped-ref-stepfrom
refactor-object-exclusion-predicate
Nov 13, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
refactor-mapped-ref-stepfrom
refactor-object-exclusion-predicate

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of inline JSON Schema branches whose declared types exclude objects.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Walkthrough

When read_object_keywords_by_type is enabled, _combined_branch_outer now uses _branch_excludes_objects as its object-exclusion check for inline branches.

Changes: JSON Schema object exclusion

Layer / File(s) Summary
Inline branch object check
src/datamodel_code_generator/parser/jsonschema.py
_combined_branch_outer now uses _branch_excludes_objects instead of a separate _types_exclude check for inline branches when read_object_keywords_by_type is enabled.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Refactor

Merge Risk: Minimal · up to 982c7

This is a small internal refactor of how the parser decides whether a branch excludes objects. No behavior change or concrete risk has been identified, so it is ready to merge after normal checks.

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 states the main change: an inline branch's object exclusion is now decided by a single predicate, _branch_excludes_objects. The raw summary confirms _combined_branch_outer now uses that …
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 states the main change: an inline branch's object exclusion is now decided by a single predicate, _branch_excludes_objects. The raw summary confirms _combined_branch_outer now uses that predicate as its sole object-exclusion check and no longer takes the separate _types_exclude path. The title is specific and matches the one-file change (+1/-3).

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 ad730f3 and 982c7a0.

Files selected for processing: 1

  • 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.

@koxudaxi
Koudai Aono (koxudaxi) marked this pull request as ready for review November 12, 2026 20:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T20:41:00.075045Z 982c7a0 Draft marked ready
ℹ️ 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 Nov 12, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 30.57%

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

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_unique_items_nested_model_validation 2.5 ms 1.6 ms +61.16%
⚡ test_perf_unique_items_runtime_scalar_validation 2.5 ms 1.6 ms +58.86%
⚡ test_perf_pydantic_field_name_resolution 1.9 ms 1.2 ms +57.34%
⚡ test_perf_duplicate_names 787.7 ms 542.1 ms +45.31%
⚡ test_perf_simple_pydantic_v2_field_construction 8.8 ms 6.1 ms +44.8%
⚡ test_perf_large_models_typed_dict[total-false-requiredness] 913.5 ms 635.2 ms +43.82%
⚡ test_perf_complex_refs 1.6 s 1.1 s +42.48%
⚡ test_perf_large_models_typed_dict[legacy-requiredness] 913.2 ms 654.9 ms +39.45%
⚡ test_perf_unique_items_schema_validators 1.6 s 1.2 s +37.84%
⚡ test_perf_unique_items_permuted_object_validation 53.1 ms 38.7 ms +37.33%
⚡ test_perf_large_models_pydantic_v2 2.7 s 2 s +37.3%
⚡ test_perf_empty_pydantic_v2_field_render_plans 28.4 ms 20.7 ms +37.06%
⚡ test_perf_unique_items_collapsed_builtin 1.6 s 1.1 s +36.66%
⚡ test_perf_large_models_msgspec 1.5 s 1.1 s +35.3%
⚡ test_perf_target_render[client-small] 28.7 ms 21.5 ms +33.78%
⚡ test_perf_pattern_properties_adapter_reuse 2.9 ms 2.2 ms +33.21%
⚡ test_perf_multiple_files_input 3.2 s 2.4 s +33.18%
⚡ test_perf_large_models_pydantic_v2_builtin_double_quotes 1,145 ms 862.7 ms +32.73%
⚡ test_perf_unique_items_runtime_nested_object_validation 5.5 ms 4.2 ms +32.16%
⚡ test_perf_extreme_large_schema 11.3 s 8.6 s +31.99%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

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


Comparing refactor-object-exclusion-predicate (982c7a0) with refactor-mapped-ref-step (ad730f3)

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. ↩

@koxudaxi
Koudai Aono (koxudaxi) merged commit 758cb11 into main Nov 13, 2026
48 of 149 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the refactor-object-exclusion-predicate branch November 13, 2026 05:05
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR changes a single condition in JsonSchemaParser in parser/jsonschema.py. The old check was a types-exclude-object test, or a ref branch that excludes objects. The new check calls only the _branch_excludes_objects helper. Both versions run only when the read_object_keywords_by_type config is enabled, so the change stays behind that option and only adjusts which branches drop object-only keywords. No CLI option, Python API, template, Python version support or error handling changed. The behaviour diff gate lists only both-fail cells, with no accepted or violation cells, so default generated output is identical to release 0.95.0. This looks like an internal refinement or bug fix, not a breaking change.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

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