Use semantic None default checks#3479
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 ignored due to path filters (1)
📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughIntroduces Changesstrip_default_none refactor and test coverage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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-3479.datamodel-code-generator.pages.dev |
Merging this PR will not alter performance
|
383842a to
35e7c4d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3479 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 151 151
Lines 32494 32498 +4
Branches 3783 3783
=========================================
+ Hits 32494 32498 +4
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:
|
35e7c4d to
00cde07
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/main/openapi/test_main_openapi.py (1)
1322-1336: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding explicit test IDs for clearer test output.
The parametrization would benefit from explicit
idsto make pytest output more readable.📝 Suggested enhancement
`@pytest.mark.parametrize`( ("output_model_type", "target_python_version", "expected_file"), [ ( "dataclasses.dataclass", "3.10", "strip_default_none_semantic_dataclass.py", ), ( "msgspec.Struct", "3.10", "strip_default_none_semantic_msgspec.py", ), ], + ids=["dataclass", "msgspec"], )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/main/openapi/test_main_openapi.py` around lines 1322 - 1336, Add explicit test IDs to the `@pytest.mark.parametrize` decorator to improve pytest output readability. Include an ids parameter as the fourth argument to the parametrize call with descriptive string identifiers for each test case (one ID for the dataclasses.dataclass case and one for the msgspec.Struct case), so that pytest reports use these meaningful names instead of the default parameter indices.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/main/openapi/test_main_openapi.py`:
- Around line 1322-1336: Add explicit test IDs to the `@pytest.mark.parametrize`
decorator to improve pytest output readability. Include an ids parameter as the
fourth argument to the parametrize call with descriptive string identifiers for
each test case (one ID for the dataclasses.dataclass case and one for the
msgspec.Struct case), so that pytest reports use these meaningful names instead
of the default parameter indices.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: efd76873-2a14-4b49-b24f-7ab5b7061e2a
⛔ Files ignored due to path filters (1)
tests/data/openapi/strip_default_none_semantic.yamlis excluded by!tests/data/**/*.yamland included by none
📒 Files selected for processing (7)
src/datamodel_code_generator/model/base.pysrc/datamodel_code_generator/model/dataclass.pysrc/datamodel_code_generator/model/msgspec.pysrc/datamodel_code_generator/model/pydantic_base.pytests/data/expected/main/openapi/strip_default_none_semantic_dataclass.pytests/data/expected/main/openapi/strip_default_none_semantic_msgspec.pytests/main/openapi/test_main_openapi.py
✅ Files skipped from review due to trivial changes (2)
- tests/data/expected/main/openapi/strip_default_none_semantic_dataclass.py
- tests/data/expected/main/openapi/strip_default_none_semantic_msgspec.py
🚧 Files skipped from review as they are similar to previous changes (4)
- src/datamodel_code_generator/model/dataclass.py
- src/datamodel_code_generator/model/base.py
- src/datamodel_code_generator/model/msgspec.py
- src/datamodel_code_generator/model/pydantic_base.py
00cde07 to
03126ae
Compare
Breaking Change AnalysisResult: No breaking changes detected Reasoning: PR #3479 is an internal, behavior-preserving refactor of the This analysis was performed by Claude Code Action |
|
🎉 Released in 0.65.1 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit
Bug Fixes
--strip-default-nonebehavior so “default None” is stripped based on semantic equality toNone, not on falsy values or string literals like'None'.None-like defaults.Tests
--target-python-version 3.10.