fix: code health cleanup and test gaps (#921, #860)#996
Merged
Conversation
136ec86 to
f5d4d4f
Compare
There was a problem hiding this comment.
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 ofgetattr/hasattr(with an intentional exception for a full-MRO regression guard). - Add tests covering
TOOL_EXECUTION_COMPLETEdetail rendering whenmodelis 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. |
f5d4d4f to
000de2e
Compare
- 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>
000de2e to
35dcaf2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #921 (code hygiene) and #860 (render_detail test gaps).
Changes
#921 — Code hygiene (3 findings):
# Typed event helperssection header inmodels.py(content was moved elsewhere)# type: ignore[arg-type]to# pyright: ignore[reportArgumentType]with correct rule names (cli.py:290,logging_config.py:56)# type: ignore[import-untyped]on watchdog import — pyright doesn't flag it (watchdog shipspy.typed)getattr/hasattrwithvars()intest_packaging.pyfor module-level checks, per "no runtime type interrogation" rulehasattrforSessionEvent.parse_dataregression guard — needs full MRO traversal to catch inherited methods on Pydantic models#860 — render_detail test gaps:
shutdownType=None): Already covered —shutdownTypeisstr(notOptional), defaults to"", and Pydantic rejectsNone. Existing tests at lines 2971 and 2984 cover the falsy branch.TOOL_EXECUTION_COMPLETEwithmodelfield): Addedtest_tool_execution_with_model_field— exercises theif data.model:branchtest_tool_execution_with_empty_model_string— documents falsymodel=""edge case behaviourReview notes
vars(SessionEvent)MRO weakness — fixed by restoringhasattrfor that specific assertionmodel=""edge case gap — test addedmake checkpasses: lint ✅ pyright ✅ bandit ✅ tests 99% ✅ e2e 86 ✅Also recommending closure of stale issues
_detect_resume: missing regression test forASSISTANT_TURN_START-only post-shutdown not marking session as [Content truncated due to length] #761:_detect_resumewas deleted in PR perf(parser): single-pass resume detection in _first_pass (#955) #990; the scenario is covered byTestOrphanedTurnStartDoesNotInflateActiveCallstest_is_dir_oserror_entry_is_skippedadded in commit 5f456e7Closes #921
Closes #860