fix: move vscode lazy imports to module level (#1183)#1185
Open
fix: move vscode lazy imports to module level (#1183)#1185
Conversation
Move `get_vscode_summary` and `render_vscode_summary` imports from inside the `vscode()` function body to the module-level import block in `cli.py`, consistent with all other subcommands. Add a regression test verifying both symbols are available as module-level attributes of `copilot_usage.cli`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Moves the VS Code subcommand dependencies in copilot_usage.cli from lazy in-function imports to module-level imports, aligning vscode with the import/command structure used by the other CLI subcommands and surfacing import errors earlier.
Changes:
- Promoted
get_vscode_summaryandrender_vscode_summaryto module-level imports insrc/copilot_usage/cli.pyand removed the deferred in-function imports. - Added a regression test asserting both symbols are present as module attributes after importing
copilot_usage.cli.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/copilot_usage/cli.py | Makes VS Code command dependencies import at module load time (consistent with other subcommands). |
| tests/copilot_usage/test_cli.py | Adds a regression test ensuring the VS Code symbols are available at module scope (no deferred import). |
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
Move
get_vscode_summaryandrender_vscode_summaryimports from inside thevscode()function body to the module-level import block incli.py, consistent with every other subcommand (summary,cost,live,session).Changes
src/copilot_usage/cli.py— Moved twofrom copilot_usage.*imports from insidevscode()to the top-level import section. Removed the now-redundant in-function import lines.tests/copilot_usage/test_cli.py— Addedtest_vscode_imports_are_module_level()regression test that verifies both symbols are available as module-level attributes ofcopilot_usage.cli(i.e., no longer deferred).Why
vscodecommand is invoked.Closes #1183
Warning
The following domains were blocked by the firewall during workflow execution:
astral.shindex.crates.iopypi.orgreleaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.