fix: parser.py / pricing.py housekeeping (#182)#191
Merged
Conversation
- Move _RESUME_INDICATOR_TYPES to module-level frozenset constant - Replace ISO string sort key with datetime sentinel (_EPOCH) - Add gpt-5.4-mini at 0.0× multiplier to _RAW_MULTIPLIERS - Add test entries for gpt-5.4-mini multiplier and tier Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Housekeeping updates in copilot_usage to reduce per-call overhead in the session parser, make session sorting more explicit/robust, and extend the pricing registry for a newly observed model name.
Changes:
- Moved resume-indicator event types to a module-level
frozensetconstant inparser.py. - Updated
get_all_sessions()sorting to use adatetimesentinel (datetime.minw/ UTC) rather than ISO string keys. - Added
gpt-5.4-minito the pricing multipliers (0.0× →LIGHT) and extended existing parametrized tests accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/copilot_usage/parser.py |
Avoids recreating invariant sets per call and replaces ISO-string sort keys with a UTC datetime sentinel. |
src/copilot_usage/pricing.py |
Registers gpt-5.4-mini at 0.0× so lookups don’t fall back to the unknown-model 1× warning path. |
tests/copilot_usage/test_pricing.py |
Extends existing parametrized coverage to include gpt-5.4-mini multiplier and tier expectations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Quality Gate: APPROVED ✅
Low-impact housekeeping PR (26 lines across 3 files). All changes verified:
_RESUME_INDICATOR_TYPES→ module-levelfrozenset— avoids per-call recreation, signals immutability. All referencedEventTypemembers validated._sort_keydatetime sentinel — replaces ISO string comparison with properdatetimeordering. Existingtest_sessions_without_start_time_sort_lastvalidates behavior.gpt-5.4-miniat0.0×— consistent withgpt-5-miniandgpt-4.1. Test parametrizations added for multiplier and tier.
No API changes, no business logic changes, no security implications. Auto-approving for merge.
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.
Closes #182
Three small housekeeping fixes:
1.
_RESUME_INDICATOR_TYPES→ module-levelfrozensetMoved the set literal from inside
build_session_summary()to a module-levelfrozensetconstant, avoiding recreation on every call and signaling immutability.2.
_sort_keyuses datetime sentinel instead of ISO stringsReplaced the ISO string comparison sort key with a
datetimesentinel (_EPOCH = datetime.min.replace(tzinfo=UTC)). Sessions withstart_time=Nonesort to_EPOCH(effectively last when sorted descending), avoiding reliance on implicit string ordering.3. Added
gpt-5.4-minito_RAW_MULTIPLIERSAdded at
0.0×multiplier (tierLIGHT), consistent withgpt-5-miniandgpt-4.1.Tests
test_sessions_without_start_time_sort_lastvalidates the sort behavior.test_known_multipliers(gpt-5.4-mini,0.0) andtest_known_tiers(gpt-5.4-mini,LIGHT).All 422 tests pass, coverage 98%, ruff/pyright clean.
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.