Summary
Three small guideline compliance issues, none worth a standalone issue, together form a meaningful cleanup pass.
1. Stale module-level docstring in cli.py
File: src/copilot_usage/cli.py, lines 1–4
Current:
"""CLI entry-point for copilot-usage.
Provides ``summary``, ``session``, ``cost``, and ``live`` commands,
plus an interactive Rich-based session when invoked without a subcommand.
"""
Problem: The vscode command (line ~653) was added later and was never mentioned in the module docstring. The docstring now misdescribes the module.
Fix: Add , vscode``` to the list of commands in the docstring.
2. getattr/hasattr in tests/test_packaging.py violates the "No getattr/hasattr" guideline
File: tests/test_packaging.py, lines 27–30
Current:
dunder_all: list[str] | None = getattr(mod, "__all__", None) # noqa: B009
...
assert hasattr(mod, name), ( # noqa: B009
Problem: .github/CODING_GUIDELINES.md prohibits getattr/hasattr. The # noqa: B009 comments suppress ruff's constant-attribute getattr warning but do not address the guideline.
Fix:
- Replace
getattr(mod, "__all__", None) with mod.__dict__.get("__all__") (avoids getattr; uses the module's raw __dict__ which is always a plain dict).
- Replace
hasattr(mod, name) with name in dir(mod) or catch AttributeError on direct access.
3. hasattr in tests/copilot_usage/test_models.py violates the same guideline
File: tests/copilot_usage/test_models.py, line 269
Current:
assert not hasattr(d, "sessionStartTime")
Problem: Uses banned hasattr. The intent is to verify that a removed Pydantic field is not stored on the model instance.
Fix: Replace with assert "sessionStartTime" not in d.__dict__ — for Pydantic v2 models without extra="allow", the instance __dict__ contains exactly the declared fields, so this is equivalent and avoids hasattr.
Testing requirement
All three fixes are mechanical one-liners with no behaviour change. Run make check to verify after applying. No new tests required; the existing tests are the regression check.
Generated by Code Health Analysis · ● 10.5M · ◷
Summary
Three small guideline compliance issues, none worth a standalone issue, together form a meaningful cleanup pass.
1. Stale module-level docstring in
cli.pyFile:
src/copilot_usage/cli.py, lines 1–4Current:
Problem: The
vscodecommand (line ~653) was added later and was never mentioned in the module docstring. The docstring now misdescribes the module.Fix: Add
,vscode``` to the list of commands in the docstring.2.
getattr/hasattrintests/test_packaging.pyviolates the "Nogetattr/hasattr" guidelineFile:
tests/test_packaging.py, lines 27–30Current:
Problem:
.github/CODING_GUIDELINES.mdprohibitsgetattr/hasattr. The# noqa: B009comments suppress ruff's constant-attributegetattrwarning but do not address the guideline.Fix:
getattr(mod, "__all__", None)withmod.__dict__.get("__all__")(avoidsgetattr; uses the module's raw__dict__which is always a plain dict).hasattr(mod, name)withname in dir(mod)or catchAttributeErroron direct access.3.
hasattrintests/copilot_usage/test_models.pyviolates the same guidelineFile:
tests/copilot_usage/test_models.py, line 269Current:
Problem: Uses banned
hasattr. The intent is to verify that a removed Pydantic field is not stored on the model instance.Fix: Replace with
assert "sessionStartTime" not in d.__dict__— for Pydantic v2 models withoutextra="allow", the instance__dict__contains exactly the declared fields, so this is equivalent and avoidshasattr.Testing requirement
All three fixes are mechanical one-liners with no behaviour change. Run
make checkto verify after applying. No new tests required; the existing tests are the regression check.