Fix --base-class-map and --enum-field-as-literal-map long inline json support#3075
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 due to trivial changes (1)
📝 WalkthroughWalkthroughWraps the filesystem check in the CLI JSON parsing helper to treat OSError from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
Merging this PR will not alter performance
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/main/jsonschema/test_main_jsonschema.py (1)
3147-3159: Consider adding the twin long-inline regression for--enum-field-as-literal-map.This test covers the long-inline JSON path for
--base-class-map, but the PR scope also includes--enum-field-as-literal-map. Adding an analogous long-inline case would prevent future divergence between the two CLI options.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/main/jsonschema/test_main_jsonschema.py` around lines 3147 - 3159, Add a sibling test to cover the long-inline JSON case for the --enum-field-as-literal-map option similar to test_main_jsonschema_base_class_map_long_json: create a new test (e.g., test_main_jsonschema_enum_field_as_literal_map_long_json) that calls run_main_and_assert with the same input_path/output_path/assert_func/expected_file pattern but pass extra_args with "--enum-field-as-literal-map" and a very long inline JSON string built with itertools.repeat (matching the 100-item pattern used in test_main_jsonschema_base_class_map_long_json) so both CLI options have equivalent long-inline regression coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/main/jsonschema/test_main_jsonschema.py`:
- Around line 3147-3159: Add a sibling test to cover the long-inline JSON case
for the --enum-field-as-literal-map option similar to
test_main_jsonschema_base_class_map_long_json: create a new test (e.g.,
test_main_jsonschema_enum_field_as_literal_map_long_json) that calls
run_main_and_assert with the same
input_path/output_path/assert_func/expected_file pattern but pass extra_args
with "--enum-field-as-literal-map" and a very long inline JSON string built with
itertools.repeat (matching the 100-item pattern used in
test_main_jsonschema_base_class_map_long_json) so both CLI options have
equivalent long-inline regression coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5e130d50-661a-4fe2-bd92-26bf9bcc66bd
📒 Files selected for processing (2)
src/datamodel_code_generator/arguments.pytests/main/jsonschema/test_main_jsonschema.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3075 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 87 87
Lines 18237 18247 +10
Branches 2087 2087
=========================================
+ Hits 18237 18247 +10
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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/main/jsonschema/test_main_jsonschema.py`:
- Around line 4677-4695: The test hunk for
test_main_enum_field_as_literal_map_long_json has formatter drift; run the
formatter and commit the changes: run ruff format on
tests/main/jsonschema/test_main_jsonschema.py (or use your project's configured
formatter) to reformat the test function
test_main_enum_field_as_literal_map_long_json and the surrounding lines, then
add and commit the updated file so the CI formatting check passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d45ecd49-08f2-426a-9a44-557044223132
📒 Files selected for processing (1)
tests/main/jsonschema/test_main_jsonschema.py
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is a pure bug fix that resolves an unhandled This analysis was performed by Claude Code Action |
|
🎉 Released in 0.56.1 This PR is now available in the latest release. See the release notes for details. |
Context
path.is_file()was used to check whether a path is a file or not.os.path.isfile()function raisesOSError.path.is_file()and similar functions behaves differently in different Python versions1:path.is_file()propagate OSError.path.is_file()catches OSError and returnsfalse.Consequence
OSErrorexception creating a crash.Now
OSErrorto alignpath.is_file()behavior of Python <=3.13 with the one implemented by Python >= 3.14.OSErroris raised bypath.is_file()Note
Summary by CodeRabbit
Bug Fixes
Tests
Footnotes
https://docs.python.org/3/library/pathlib.html#querying-file-type-and-status ↩