Skip to content

fix: update stale docstring and suppress UserWarning in cost rendering (#198)#214

Merged
microsasa merged 2 commits intomainfrom
fix/198-stale-docstring-noisy-warning-d8546e14e1da929e
Mar 21, 2026
Merged

fix: update stale docstring and suppress UserWarning in cost rendering (#198)#214
microsasa merged 2 commits intomainfrom
fix/198-stale-docstring-noisy-warning-d8546e14e1da929e

Conversation

@microsasa
Copy link
Owner

Summary

Fixes two issues from #198 (unresolved review comments from PR #189):

1. Stale docstring in render_cost_view

The 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 UserWarning for unknown models

lookup_model_pricing() emits a UserWarning when 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 the lookup_model_pricing call in warnings.catch_warnings() to suppress UserWarning within the rendering path, so unknown models degrade gracefully to the default 1× multiplier.

Tests added

  • TestEstimatePremiumCost: unit tests for _estimate_premium_cost including a no-warning assertion for unknown models
  • test_active_session_unknown_model_no_warning: integration test verifying render_cost_view emits no warnings with unknown models

Verification

All CI checks pass locally:

  • ruff check
  • ruff format
  • pyright ✅ (0 errors)
  • pytest --cov --cov-fail-under=80 ✅ (442 passed, 98% coverage)

Closes #198

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"

See Network Configuration for more information.

Copilot AI review requested due to automatic review settings March 21, 2026 15:49
@microsasa microsasa added the aw Created by agentic workflow label Mar 21, 2026
@microsasa microsasa enabled auto-merge March 21, 2026 15:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 UserWarning from lookup_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 (not N/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.

@microsasa microsasa added the aw-review-response-attempted Responder has attempted to address review comments label Mar 21, 2026
@github-actions
Copy link
Contributor

Commit pushed: 63400f8

Generated by Review Responder

@microsasa microsasa disabled auto-merge March 21, 2026 16:12
@microsasa microsasa enabled auto-merge March 21, 2026 16:12
github-actions bot and others added 2 commits March 21, 2026 16:17
#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>
Copilot AI review requested due to automatic review settings March 21, 2026 16:17
@microsasa microsasa force-pushed the fix/198-stale-docstring-noisy-warning-d8546e14e1da929e branch from 63400f8 to 18fe595 Compare March 21, 2026 16:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Mar 21, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Quality Gate: Auto-approved

Low-impact fix with good test coverage:

  • Suppresses UserWarning noise from lookup_model_pricing() during CLI rendering using standard warnings.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)

@microsasa microsasa merged commit a091f59 into main Mar 21, 2026
8 checks passed
@microsasa microsasa deleted the fix/198-stale-docstring-noisy-warning-d8546e14e1da929e branch March 21, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR aw-review-response-attempted Responder has attempted to address review comments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] Stale docstring and noisy UserWarning in pricing/cost rendering

2 participants