Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses two UX/documentation issues in the Copilot usage reporting layer: it updates render_cost_view’s docstring to reflect current behavior and prevents lookup_model_pricing() warnings from leaking into normal CLI rendering when a session references an unknown model.
Changes:
- Suppress
UserWarningfromlookup_model_pricing()inside_estimate_premium_cost()so unknown models degrade silently to the default 1× multiplier during rendering. - Update
render_cost_view’s docstring to state that the “↳ Since last shutdown” row shows an estimated premium cost (notN/A). - Add unit/integration tests covering unknown-model behavior and ensuring no warnings are emitted during cost rendering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/copilot_usage/report.py |
Suppresses pricing lookup warnings within _estimate_premium_cost and updates the render_cost_view docstring. |
tests/copilot_usage/test_report.py |
Adds tests for _estimate_premium_cost and verifies cost view rendering emits no warnings for unknown models. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Commit pushed:
|
#198) - Update render_cost_view docstring to reflect that it renders an estimated premium cost (not N/A) for active sessions. - Suppress UserWarning inside _estimate_premium_cost so unknown models degrade gracefully to the default 1× multiplier without noisy output. - Add tests for _estimate_premium_cost (including no-warning assertion) and for render_cost_view with unknown model. Closes #198 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
63400f8 to
18fe595
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Quality Gate: Auto-approved ✅
Low-impact fix with good test coverage:
- Suppresses
UserWarningnoise fromlookup_model_pricing()during CLI rendering using standardwarnings.catch_warnings()— correctly scoped, no global side effects - Fixes two stale docstrings to match actual behavior
- Adds 5 meaningful tests (4 unit + 1 integration) covering the fix
Impact: LOW (localized rendering helper change + documentation + tests)
Summary
Fixes two issues from #198 (unresolved review comments from PR #189):
1. Stale docstring in
render_cost_viewThe docstring claimed the "↳ Since last shutdown" row uses N/A for premium cost, but the code actually renders an estimated value via
_estimate_premium_cost. Updated the docstring to match reality.2. Noisy
UserWarningfor unknown modelslookup_model_pricing()emits aUserWarningwhen it encounters an unknown model name. Since_estimate_premium_cost()is called during normal CLI rendering, this warning surfaces on stderr for end users. Fixed by wrapping thelookup_model_pricingcall inwarnings.catch_warnings()to suppressUserWarningwithin the rendering path, so unknown models degrade gracefully to the default 1× multiplier.Tests added
TestEstimatePremiumCost: unit tests for_estimate_premium_costincluding a no-warning assertion for unknown modelstest_active_session_unknown_model_no_warning: integration test verifyingrender_cost_viewemits no warnings with unknown modelsVerification
All CI checks pass locally:
ruff check✅ruff format✅pyright✅ (0 errors)pytest --cov --cov-fail-under=80✅ (442 passed, 98% coverage)Closes #198
Warning
The following domain was blocked by the firewall during workflow execution:
astral.shTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.