Skip to content

Type reference sources#3591

Merged
koxudaxi merged 2 commits into
mainfrom
agent/reference-child-protocol
Jul 7, 2026
Merged

Type reference sources#3591
koxudaxi merged 2 commits into
mainfrom
agent/reference-child-protocol

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Refactor
    • Refined type annotations for reference source information to improve correctness during development.
    • Ensures the same runtime behavior and user-facing output as before, with no functional changes.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@koxudaxi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 1 minute

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a35a0ea-523d-4385-acb8-aeb058aef395

📥 Commits

Reviewing files that changed from the base of the PR and between 6475d4d and 10ce1c8.

📒 Files selected for processing (1)
  • src/datamodel_code_generator/reference.py
📝 Walkthrough

Walkthrough

The change refines typing for Reference.source in reference.py by introducing a TYPE_CHECKING-only protocol _ReferenceSource, aliasing it to ReferenceChild at runtime, and updating the field annotation accordingly.

Changes

Reference Typing Refinement

Layer / File(s) Summary
Protocol and field annotation update
src/datamodel_code_generator/reference.py
Adds a TYPE_CHECKING-only _ReferenceSource protocol, imports DataModelFieldBase to support it, aliases _ReferenceSource to ReferenceChild at runtime, and updates Reference.source to use _ReferenceSource.

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

Related Issues: None specified.

Related PRs: None specified.

Suggested labels: typing, refactor

Suggested reviewers: koxudaxi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: refining the type of reference sources.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/reference-child-protocol

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.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📚 Docs Preview: https://pr-3591.datamodel-code-generator.pages.dev

Comment thread src/datamodel_code_generator/reference.py Fixed
Comment thread src/datamodel_code_generator/reference.py Fixed
Comment thread src/datamodel_code_generator/reference.py Fixed
Comment thread src/datamodel_code_generator/reference.py Fixed
Comment thread src/datamodel_code_generator/reference.py Fixed
@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 15.16%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 13 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_perf_large_models_pydantic_v2_noformat 700.1 ms 859.1 ms -18.51%
WallTime test_perf_large_models_pydantic_v2_builtin 749.2 ms 910.4 ms -17.7%
WallTime test_perf_large_models_pydantic_v2 2.9 s 3.5 s -16.47%
WallTime test_perf_deep_nested 4.3 s 5.1 s -15.48%
WallTime test_perf_openapi_large 2.4 s 2.9 s -15.45%
WallTime test_perf_complex_refs 1.6 s 1.9 s -15.35%
WallTime test_perf_multiple_files_input 2.9 s 3.4 s -14.97%
WallTime test_perf_duplicate_names 875.2 ms 1,027 ms -14.79%
WallTime test_perf_all_options_enabled 4.5 s 5.3 s -14.72%
WallTime test_perf_aws_style_openapi_pydantic_v2 1.6 s 1.9 s -14.28%
WallTime test_perf_kubernetes_style_pydantic_v2 2.2 s 2.5 s -13.81%
WallTime test_perf_graphql_style_pydantic_v2 668 ms 773.6 ms -13.66%
WallTime test_perf_stripe_style_pydantic_v2 1.7 s 1.9 s -11.68%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing agent/reference-child-protocol (10ce1c8) with main (ec07ba2)

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 Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7cf7486) to head (10ce1c8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3591   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          164       164           
  Lines        35287     35288    +1     
  Branches      4075      4075           
=========================================
+ Hits         35287     35288    +1     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi force-pushed the agent/reference-child-protocol branch 2 times, most recently from 2b83bcd to 6475d4d Compare July 7, 2026 17:34
@koxudaxi koxudaxi merged commit 3677f13 into main Jul 7, 2026
60 of 61 checks passed
@koxudaxi koxudaxi deleted the agent/reference-child-protocol branch July 7, 2026 17:45
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: Type-annotation-only changes to an internal module with no runtime, generated-output, CLI, or template impact.


This analysis was performed by Claude Code Action

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.68.1

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