Fix set/frozenset duplicate output in x-python-type serialization#2849
Fix set/frozenset duplicate output in x-python-type serialization#2849
Conversation
📝 WalkthroughWalkthroughThe PR updates Python set type handling by changing the preserved type origins from capitalized "Set"/"FrozenSet" to lowercase "set"/"frozenset" and adds corresponding JSON Schema parser support for the lowercase variants, enabling consistent handling of both naming conventions. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
🔇 Additional comments (2)
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-2849.datamodel-code-generator.pages.dev |
CodSpeed Performance ReportMerging #2849 will improve performance by 23.31%Comparing
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_perf_multiple_files_input |
3.9 s | 3.2 s | +20.93% |
| ⚡ | WallTime | test_perf_complex_refs |
2.2 s | 1.8 s | +22.99% |
| ⚡ | WallTime | test_perf_duplicate_names |
1,048.7 ms | 869.2 ms | +20.65% |
| ⚡ | WallTime | test_perf_stripe_style_pydantic_v2 |
2.1 s | 1.8 s | +20.49% |
| ⚡ | WallTime | test_perf_graphql_style_pydantic_v2 |
877 ms | 727.3 ms | +20.58% |
| ⚡ | WallTime | test_perf_large_models_pydantic_v2 |
3.7 s | 3.1 s | +19.12% |
| ⚡ | WallTime | test_perf_deep_nested |
6.2 s | 5.4 s | +15.82% |
| ⚡ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
2.1 s | 1.7 s | +19.98% |
| ⚡ | WallTime | test_perf_all_options_enabled |
6.9 s | 5.8 s | +17.82% |
| ⚡ | WallTime | test_perf_openapi_large |
3.1 s | 2.5 s | +21.17% |
| ⚡ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.8 s | 2.3 s | +23.31% |
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 #2849 +/- ##
=======================================
Coverage 99.50% 99.50%
=======================================
Files 90 90
Lines 14489 14489
Branches 1736 1736
=======================================
Hits 14417 14417
Misses 37 37
Partials 35 35
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is a bug fix that changes the internal x-python-type serialization format from uppercase "Set"/"FrozenSet" to lowercase "set"/"frozenset" to match Python's modern convention. The change affects only the intermediate JSON Schema representation, not the final generated Python code output. Users' generated code remains unchanged (still produces set[str], frozenset[int], etc.). Additionally, the PR adds backward compatibility in the parser by supporting both uppercase and lowercase variants when reading JSON schemas, so existing schemas with x-python-type: "Set[str]" continue to work correctly. This analysis was performed by Claude Code Action |
|
🎉 Released in 0.51.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.