Use __qualname__ for nested class support and add DefaultPutDict test#2859
Use __qualname__ for nested class support and add DefaultPutDict test#2859
Conversation
|
📚 Docs Preview: https://pr-2859.datamodel-code-generator.pages.dev |
📝 WalkthroughWalkthroughThis PR modifies the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
CodSpeed Performance ReportMerging #2859 will not alter performanceComparing
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2859 +/- ##
=======================================
Coverage 99.52% 99.52%
=======================================
Files 90 90
Lines 14935 14938 +3
Branches 1788 1788
=======================================
+ Hits 14864 14867 +3
Misses 38 38
Partials 33 33
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:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/data/python/input_model/pydantic_models.py (1)
108-119: LGTM! Consider minor cleanup of unused directive.The new
ModelWithDefaultPutDictmodel correctly tests the__qualname__change for real-world generic types from the parser module. The structure follows the existing pattern for custom generic types.🔎 Optional: Remove unused noqa directive
Ruff reports that the
noqa: E402directive is unused because E402 is not enabled. Consider removing it:-from datamodel_code_generator.parser import DefaultPutDict # noqa: E402 +from datamodel_code_generator.parser import DefaultPutDictIf the directive is intended for other linters (e.g., flake8), you can keep it. However, if only ruff is used, it's unnecessary.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/datamodel_code_generator/__main__.pytests/data/python/input_model/pydantic_models.pytests/test_input_model.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/data/python/input_model/pydantic_models.py (1)
src/datamodel_code_generator/parser/__init__.py (1)
DefaultPutDict(28-47)
🪛 Ruff (0.14.10)
tests/data/python/input_model/pydantic_models.py
111-111: Unused noqa directive (non-enabled: E402)
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). (2)
- GitHub Check: combine coverage
- GitHub Check: benchmarks
🔇 Additional comments (2)
src/datamodel_code_generator/__main__.py (1)
695-697: LGTM! Excellent improvement for nested class support.The change to use
__qualname__with a fallback to__name__correctly handles nested classes. For example, a nested generic likeOuterClass.InnerClass[T]will now be properly represented asmodule.OuterClass.InnerClass[T]instead ofmodule.InnerClass[T], avoiding potential name collisions and improving clarity.The fallback ensures backward compatibility for any edge cases where
__qualname__might not be available.tests/test_input_model.py (1)
744-756: LGTM! Well-structured test for DefaultPutDict support.The test properly validates that
DefaultPutDictfrom the parser module is correctly imported and represented in generated output. It mirrors the existing pattern for custom generic types and covers both non-optional and optional usage scenarios.
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR changes from using 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
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.