Skip to content

fix: code health cleanup and test gaps (#921, #860)#996

Merged
microsasa merged 1 commit intomainfrom
fix/close-stale-and-code-health-761-846-860-921
Apr 19, 2026
Merged

fix: code health cleanup and test gaps (#921, #860)#996
microsasa merged 1 commit intomainfrom
fix/close-stale-and-code-health-761-846-860-921

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Summary

Addresses #921 (code hygiene) and #860 (render_detail test gaps).

Changes

#921 — Code hygiene (3 findings):

  • Remove dead # Typed event helpers section header in models.py (content was moved elsewhere)
  • Convert mypy-style # type: ignore[arg-type] to # pyright: ignore[reportArgumentType] with correct rule names (cli.py:290, logging_config.py:56)
  • Remove unnecessary # type: ignore[import-untyped] on watchdog import — pyright doesn't flag it (watchdog ships py.typed)
  • Replace getattr/hasattr with vars() in test_packaging.py for module-level checks, per "no runtime type interrogation" rule
  • Intentionally keep hasattr for SessionEvent.parse_data regression guard — needs full MRO traversal to catch inherited methods on Pydantic models

#860 — render_detail test gaps:

  • Gap 1 (shutdownType=None): Already covered — shutdownType is str (not Optional), defaults to "", and Pydantic rejects None. Existing tests at lines 2971 and 2984 cover the falsy branch.
  • Gap 2 (TOOL_EXECUTION_COMPLETE with model field): Added test_tool_execution_with_model_field — exercises the if data.model: branch
  • Added test_tool_execution_with_empty_model_string — documents falsy model="" edge case behaviour

Review notes

  • Triple adversarial review by Codex, Opus 4.6, and Sonnet 4.6
  • Opus/Sonnet both caught the vars(SessionEvent) MRO weakness — fixed by restoring hasattr for that specific assertion
  • Sonnet caught the model="" edge case gap — test added
  • make check passes: lint ✅ pyright ✅ bandit ✅ tests 99% ✅ e2e 86 ✅

Also recommending closure of stale issues

Closes #921
Closes #860

Copilot AI review requested due to automatic review settings April 19, 2026 06:13
@microsasa microsasa added code-health Code cleanup and maintenance test-audit Test coverage gaps labels Apr 19, 2026
@microsasa microsasa force-pushed the fix/close-stale-and-code-health-761-846-860-921 branch from 136ec86 to f5d4d4f Compare April 19, 2026 06:15
Copy link
Copy Markdown

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 maintenance efforts in copilot_usage: (1) code hygiene cleanups (type-ignore style consistency, removing dead comments, avoiding getattr/hasattr in packaging tests), and (2) closing test coverage gaps for render_detail._build_event_details().

Changes:

  • Standardize type-check suppression comments to # pyright: ignore[...] and remove an unnecessary watchdog import suppression.
  • Update packaging/public-API tests to use vars() lookups instead of getattr/hasattr (with an intentional exception for a full-MRO regression guard).
  • Add tests covering TOOL_EXECUTION_COMPLETE detail rendering when model is present or an empty string.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_packaging.py Switches module API checks to vars() and keeps one intentional hasattr regression guard.
tests/copilot_usage/test_report.py Adds tests for tool execution detail rendering with model field.
src/copilot_usage/models.py Removes a stale section header comment.
src/copilot_usage/logging_config.py Converts mypy-style ignore to pyright-style ignore for logger.configure.
src/copilot_usage/cli.py Removes unneeded watchdog import ignore; converts schedule ignore to pyright-style.
.github/aw/actions-lock.json Updates action lock entries, but currently includes unresolved conflict markers.

Comment thread .github/aw/actions-lock.json Outdated
Comment thread tests/test_packaging.py Outdated
@microsasa microsasa force-pushed the fix/close-stale-and-code-health-761-846-860-921 branch from f5d4d4f to 000de2e Compare April 19, 2026 06:20
- Remove dead '# Typed event helpers' section header in models.py
- Convert 3 mypy-style type: ignore to pyright: ignore with correct rule
- Remove unnecessary import-untyped suppress (pyright doesn't flag it)
- Replace getattr/hasattr with vars() in test_packaging.py (module-level)
- Keep hasattr for SessionEvent.parse_data guard (needs full MRO check)
- Add test for TOOL_EXECUTION_COMPLETE with model field (#860 gap 2)
- Add test for TOOL_EXECUTION_COMPLETE with model='' (falsy edge case)
- Restore actions-lock.json (had stale merge conflict markers)

Closes #921
Partially addresses #860 (gap 1 already covered by existing tests)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa force-pushed the fix/close-stale-and-code-health-761-846-860-921 branch from 000de2e to 35dcaf2 Compare April 19, 2026 06:36
@microsasa microsasa merged commit 28f6f66 into main Apr 19, 2026
4 checks passed
@microsasa microsasa deleted the fix/close-stale-and-code-health-761-846-860-921 branch April 19, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-health Code cleanup and maintenance test-audit Test coverage gaps

Projects

None yet

2 participants