Handle Annotated types in _serialize_python_type for TypedDict generation#2867
Handle Annotated types in _serialize_python_type for TypedDict generation#2867
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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-2867.datamodel-code-generator.pages.dev |
a8e357e to
e6bedb1
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/datamodel_code_generator/__main__.py (1)
859-859: Consider cleaning up potentially unusednoqadirectives.Static analysis suggests the
noqadirectives on lines 859 and 888 may be unnecessary. You could remove them and verify whether warnings actually appear.Also applies to: 888-888
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/datamodel_code_generator/__main__.py
🧰 Additional context used
🪛 Ruff (0.14.10)
src/datamodel_code_generator/__main__.py
859-859: Unused noqa directive (non-enabled: PLR0911)
Remove unused noqa directive
(RUF100)
888-888: Unused noqa directive (non-enabled: PLC0415)
Remove unused noqa directive
(RUF100)
⏰ 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). (14)
- GitHub Check: py312-isort7 on Ubuntu
- GitHub Check: 3.10 on Windows
- GitHub Check: 3.12 on Ubuntu
- GitHub Check: py312-black22 on Ubuntu
- GitHub Check: py312-black23 on Ubuntu
- GitHub Check: py312-black24 on Ubuntu
- GitHub Check: 3.14 on Ubuntu
- GitHub Check: 3.11 on Windows
- GitHub Check: 3.13 on Windows
- GitHub Check: 3.12 on Windows
- GitHub Check: 3.14 on Windows
- GitHub Check: 3.13 on macOS
- GitHub Check: benchmarks
- GitHub Check: Analyze (python)
🔇 Additional comments (1)
src/datamodel_code_generator/__main__.py (1)
887-893: LGTM! Correctly handles Annotated types.The logic properly extracts the base type from
Annotatedwrappers by takingargs[0]and recursively serializing it. This ensures that container types likedefaultdictare preserved when wrapped inAnnotated[...]. The fallback to_simple_type_nameand edge case handling are appropriate.
CodSpeed Performance ReportMerging #2867 will not alter performanceComparing
|
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR adds handling for 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
Annotatedtypes, enabling the tool to correctly handle complex type definitions with metadata during code generation.✏️ Tip: You can customize this high-level summary in your review settings.