Skip to content

fix: correct bugs in expense_analysis example#152

Open
Hupperich-Manuel wants to merge 1 commit intopydantic:mainfrom
Hupperich-Manuel:fix/expense-analysis-example-bugs
Open

fix: correct bugs in expense_analysis example#152
Hupperich-Manuel wants to merge 1 commit intopydantic:mainfrom
Hupperich-Manuel:fix/expense-analysis-example-bugs

Conversation

@Hupperich-Manuel
Copy link

Summary

Fix two bugs in examples/expense_analysis/data.py that prevented the example from running correctly.

Bug Fixes

1. get_expenses() - Wrong dictionary key

  • Before: return {..., 'items': items}
  • After: return {..., 'expenses': items}
  • Reason: main.py line 56 calls expenses_data.get("expenses", []), so the key must be "expenses" not "items"

2. get_custom_budget() - Missing return statement

  • Before: custom_budgets.get(user_id) (result was discarded)
  • After: Added proper logic to return budget info or None

Testing

Ran python examples/expense_analysis/main.py and confirmed it now produces correct output:
{'total_team_members_analyzed': 5, 'count_exceeded_budget': 1, 'over_budget_details': [{'name': 'Carol Jones', 'total_spent': 6740.0, 'budget': 5000, 'amount_over': 1740.0}]}

- Fix get_expenses return key from 'items' to 'expenses' to match consumer expectation
- Fix get_custom_budget to actually return the budget data instead of discarding it
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 13 untouched benchmarks


Comparing Hupperich-Manuel:fix/expense-analysis-example-bugs (edc2c8a) with main (fc2f154)

Open in CodSpeed

Copy link

@Embers-of-the-Fire Embers-of-the-Fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works, lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants