feat(models): add AssetBalance and Balance models for per-asset balan… - #51
Conversation
…ce breakdown - AssetBalance: asset_code, asset_issuer (optional), balance (Decimal) - Balance: id, merchant_id, balances list with get() helper - get() returns None for missing assets instead of raising - Case-insensitive lookup, camelCase alias support - 20 new tests, all 220 tests passing
📝 WalkthroughWalkthroughAdds ChangesBalance models and validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shade/models/balance.py (1)
45-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a
default_factoryforbalances.This makes the per-instance list default explicit and avoids RUF012.
Proposed fix
- balances: List[AssetBalance] = [] + balances: list[AssetBalance] = Field(default_factory=list)🤖 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 `@src/shade/models/balance.py` at line 45, Update the balances field declaration in the model to use the dataclass field default_factory with a list factory instead of assigning a mutable list directly. Preserve the List[AssetBalance] type and ensure each model instance receives its own empty list.Source: Linters/SAST tools
🤖 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 `@src/shade/models/balance.py`:
- Line 45: Update the balances field declaration in the model to use the
dataclass field default_factory with a list factory instead of assigning a
mutable list directly. Preserve the List[AssetBalance] type and ensure each
model instance receives its own empty list.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 32424ee6-c892-4a67-aadc-347e150c535c
📒 Files selected for processing (4)
src/shade/__init__.pysrc/shade/models/__init__.pysrc/shade/models/balance.pytests/test_balance.py
codebestia
left a comment
There was a problem hiding this comment.
LGTM!
Nice Implementation.
Thank you for your contribution.
Closes #43
breakdown
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
Summary by CodeRabbit
New Features
Tests