add example contract#130
Conversation
WalkthroughAdds ChangesUser profile storage example
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✨ 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 |
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@examples/user_profile.py`:
- Around line 32-38: Update the payload parsing for both set_grouped and the
other set command around their respective split calls to use a maximum of two
delimiters, preserving any remaining colons in the name field. Keep the existing
three-part validation and age/name assignment behavior unchanged.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 376f7e85-d5ef-4b10-8541-36df8f9fa132
📒 Files selected for processing (1)
examples/user_profile.py
| if payload.startswith('set_grouped:'): | ||
| parts = payload.split(':') | ||
| if len(parts) != 3: | ||
| raise Exception("Invalid format. Use set_grouped:<age>:<name>") | ||
|
|
||
| age = int(parts[1]) | ||
| name = parts[2] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Names containing colons are rejected by the parser.
payload.split(':') without a maxsplit limit produces more than 3 parts when the name itself contains a colon (e.g., set_grouped:25:John:Doe → 4 parts → "Invalid format"). Since <name> is the last field, use split(':', 2) so the name captures any remaining colons.
🐛 Proposed fix for both set commands
if payload.startswith('set_grouped:'):
- parts = payload.split(':')
+ parts = payload.split(':', 2)
if len(parts) != 3: elif payload.startswith('set_composite:'):
- parts = payload.split(':')
+ parts = payload.split(':', 2)
if len(parts) != 3:Also applies to: 69-75
🧰 Tools
🪛 Ruff (0.15.21)
[warning] 35-35: Create your own exception
(TRY002)
[warning] 35-35: Avoid specifying long messages outside the exception class
(TRY003)
🤖 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 `@examples/user_profile.py` around lines 32 - 38, Update the payload parsing
for both set_grouped and the other set command around their respective split
calls to use a maximum of two delimiters, preserving any remaining colons in the
name field. Keep the existing three-part validation and age/name assignment
behavior unchanged.
|
|
||
| new_age = int(parts[1]) | ||
|
|
||
| # Notice the inefficiency here: we must load the entire dict, |
There was a problem hiding this comment.
We are not loading the entire dict. We are loading the entire profile.
Addressed Issues:
Fixes #(TODO:issue number)
Screenshots/Recordings:
TODO: If applicable, add screenshots or recordings that demonstrate the interface before and after the changes.
Additional Notes:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
Checklist
Summary by CodeRabbit