Conversation
|
Warning Rate limit exceeded@koxudaxi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 8 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughMutable default values are replaced with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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-2862.datamodel-code-generator.pages.dev |
CodSpeed Performance ReportMerging #2862 will not alter performanceComparing
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2862 +/- ##
=======================================
Coverage 99.38% 99.38%
=======================================
Files 91 91
Lines 15555 15555
Branches 1827 1827
=======================================
Hits 15460 15460
Misses 50 50
Partials 45 45
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 (3)
src/datamodel_code_generator/parser/jsonschema.py (1)
22-24: JsonSchemaObject list defaults viaField(default_factory=...)look correct and improve safetySwitching
oneOf,anyOf,allOf,enum, andrequiredtoField(default_factory=list)is consistent with how these fields are used:
- Call sites treat
oneOf/anyOf/allOf/enumas lists or via truthiness, so always having a list (possibly empty) matches expectations.requiredis already normalized byvalidate_required()to[]forNone/weird inputs, and other code only checks it via truthiness or iterates it; having an empty list instead ofNonepreserves behavior. Theobj.required is Nonebranch inparse_object_fields()becomes dead but harmless.Low‑priority nits:
- You could simplify
requiresinparse_object_fields()sincerequiredis now always a list.- Ruff reports unused
noqacodes on these lines (e.g.,N815,UP045not enabled); if you want a clean lint run, consider dropping or narrowing them.Also applies to: 354-357, 361-361
src/datamodel_code_generator/types.py (1)
29-32: DataType list defaults viaField(default_factory=list)are consistent with existing usageUsing
Field(default_factory=list)fordata_types,literals,enum_member_literals, andchildrenaligns with how these fields are treated everywhere:
- They are always consumed as lists (iteration,
len(...), truthiness), so an always‑list default is appropriate.- It avoids any chance of shared mutable defaults across instances, while remaining compatible with
__deepcopy__,__init__’s parent propagation, and the dynamically createdContextDataTypeviacreate_model.Minor lint note:
- Ruff flags some
noqacodes on these lines (e.g.,UP007,UP045) as unused; you can drop or narrow them later if you want a quieter lint run.Also applies to: 431-431, 445-447, 452-452
src/datamodel_code_generator/parser/openapi.py (1)
18-18: OpenAPI model container defaults viaField(default_factory=...)are safe and match call‑site expectationsThe new defaults for
content,headers,tags,parameters,responses, and allComponentsObjectdicts look correct:
- Callers (
parse_all_parameters,parse_request_body,parse_responses,parse_operation) already treat these attributes as dictionaries/lists and never distinguish betweenNoneand “no entries”.- Using
Field(default_factory=dict/list)removes any possibility of shared mutable state between model instances and keeps semantics the same for “missing vs. empty” in the OpenAPI documents.Optional lint cleanup:
- Ruff reports several adjacent
# noqadirectives (e.g.,UP007,UP045,N815) as unused; you can safely trim or narrow them in a follow‑up if you want cleaner lint output.Also applies to: 124-137, 143-143, 151-152, 158-165, 171-175
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/datamodel_code_generator/parser/jsonschema.pysrc/datamodel_code_generator/parser/openapi.pysrc/datamodel_code_generator/types.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/datamodel_code_generator/parser/jsonschema.py (1)
tests/data/expected/parser/openapi/openapi_parser_parse_modular/bar.py (1)
Field(6-7)
src/datamodel_code_generator/types.py (1)
src/datamodel_code_generator/model/base.py (1)
DataModelFieldBase(151-469)
🪛 Ruff (0.14.10)
src/datamodel_code_generator/parser/jsonschema.py
354-354: Unused noqa directive (non-enabled: N815)
Remove unused noqa directive
(RUF100)
355-355: Unused noqa directive (non-enabled: N815)
Remove unused noqa directive
(RUF100)
356-356: Unused noqa directive (non-enabled: N815)
Remove unused noqa directive
(RUF100)
358-358: Unused noqa directive (non-enabled: N815, UP045)
Remove unused noqa directive
(RUF100)
359-359: Unused noqa directive (non-enabled: N815, UP045)
Remove unused noqa directive
(RUF100)
360-360: Unused noqa directive (non-enabled: UP007, UP045)
Remove unused noqa directive
(RUF100)
src/datamodel_code_generator/parser/openapi.py
142-142: Unused noqa directive (non-enabled: UP045)
Remove unused noqa directive
(RUF100)
150-150: Unused noqa directive (non-enabled: UP045)
Remove unused noqa directive
(RUF100)
152-152: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
159-159: Unused noqa directive (non-enabled: UP045)
Remove unused noqa directive
(RUF100)
160-160: Unused noqa directive (non-enabled: UP045)
Remove unused noqa directive
(RUF100)
161-161: Unused noqa directive (non-enabled: N815, UP045)
Remove unused noqa directive
(RUF100)
162-162: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
163-163: Unused noqa directive (non-enabled: N815, UP007, UP045)
Remove unused noqa directive
(RUF100)
164-164: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
171-171: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
172-172: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
173-173: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
174-174: Unused noqa directive (non-enabled: N815, UP007)
Remove unused noqa directive
(RUF100)
175-175: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
src/datamodel_code_generator/types.py
445-445: Unused noqa directive (non-enabled: UP007)
Remove unused noqa directive
(RUF100)
450-450: Unused noqa directive (non-enabled: UP045)
Remove unused noqa directive
(RUF100)
451-451: Unused noqa directive (non-enabled: UP007)
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). (9)
- GitHub Check: py312-isort7 on Ubuntu
- GitHub Check: 3.13 on Windows
- GitHub Check: 3.10 on Windows
- GitHub Check: 3.11 on Windows
- GitHub Check: 3.10 on macOS
- GitHub Check: 3.12 on Windows
- GitHub Check: 3.14 on Windows
- GitHub Check: benchmarks
- GitHub Check: Analyze (python)
223a237 to
1c352e0
Compare
1c352e0 to
96360b7
Compare
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR changes internal Pydantic model field defaults from mutable defaults (e.g., 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.