Fix pydantic typed extra runtime compatibility#3601
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe parser centralizes deferred-annotation handling for typed extras and tracks aliased forward references more precisely. New JSON Schema fixtures and regression tests cover self-references and union operators, while tox and coverage matrices add Pydantic 2.13. ChangesTyped extras handling
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
📚 Docs Preview: https://pr-3601.datamodel-code-generator.pages.dev |
Merging this PR will degrade performance by 14.11%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | test_perf_large_models_pydantic_v2_noformat |
667.3 ms | 844.7 ms | -21% |
| ❌ | WallTime | test_perf_large_models_pydantic_v2_builtin |
728.9 ms | 863.1 ms | -15.54% |
| ❌ | WallTime | test_perf_deep_nested |
4.3 s | 5 s | -14.88% |
| ❌ | WallTime | test_perf_all_options_enabled |
4.4 s | 5.2 s | -14.3% |
| ❌ | WallTime | test_perf_duplicate_names |
869.7 ms | 1,013.6 ms | -14.2% |
| ❌ | WallTime | test_perf_multiple_files_input |
2.9 s | 3.4 s | -14.17% |
| ❌ | WallTime | test_perf_large_models_pydantic_v2 |
2.9 s | 3.4 s | -13.79% |
| ❌ | WallTime | test_perf_openapi_large |
2.4 s | 2.8 s | -13.76% |
| ❌ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
1.6 s | 1.9 s | -13.21% |
| ❌ | WallTime | test_perf_complex_refs |
1.7 s | 2 s | -12.8% |
| ❌ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.2 s | 2.5 s | -12.47% |
| ❌ | WallTime | test_perf_graphql_style_pydantic_v2 |
663.9 ms | 754.3 ms | -11.98% |
| ❌ | WallTime | test_perf_stripe_style_pydantic_v2 |
1.7 s | 1.9 s | -10.92% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing fix/pydantic-extra-runtime-compatibility (bc0eac5) with main (1828eff)
Footnotes
-
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3601 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 164 164
Lines 35498 35526 +28
Branches 4092 4094 +2
=========================================
+ Hits 35498 35526 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Breaking Change AnalysisResult: No breaking changes detected Reasoning: PR #3601 ("Fix pydantic typed extra runtime compatibility") is a bug fix, not a breaking change. It reworks internal selection of the typed-extra annotation mode so generated code for typed-extra self/forward-referencing Pydantic v2 models is runtime-safe (keeping forward refs quoted, computing deferred-annotation state from with_import/disable_future_imports). No CLI options, public classes, enum values, or documented API functions are removed in the diff — the only rename (use_pydantic_extra_annotations_dict → is_pydantic_extra_field) is an internal getattr-accessed field attribute. Generated output changes only for previously-broken typed-extra cases, turning invalid runtime code into working code, which is a fix rather than a regression. No Python version support is dropped (a pydantic213/Python 3.14 test env is added). Remaining changes are tests, fixtures, and CI/tox config. This analysis was performed by Claude Code Action |
Summary by CodeRabbit
additionalProperties“typed extras”, including self-references with nullable/optional handling and correct behavior when targeting newer Python versions and disabling future imports.pydantic213and extended shared pytest coverage cases.