Skip to content

fix: move vscode lazy imports to module level (#1183)#1185

Open
microsasa wants to merge 1 commit intomainfrom
fix/1183-vscode-module-level-imports-1d86e1fb7c8c43d8
Open

fix: move vscode lazy imports to module level (#1183)#1185
microsasa wants to merge 1 commit intomainfrom
fix/1183-vscode-module-level-imports-1d86e1fb7c8c43d8

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Summary

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 every other subcommand (summary, cost, live, session).

Changes

  • src/copilot_usage/cli.py — Moved two from copilot_usage.* imports from inside vscode() to the top-level import section. Removed the now-redundant in-function import lines.
  • tests/copilot_usage/test_cli.py — Added test_vscode_imports_are_module_level() regression test that verifies both symbols are available as module-level attributes of copilot_usage.cli (i.e., no longer deferred).

Why

  1. Import errors now surface at process start instead of only when the vscode command is invoked.
  2. Aligns with the CODING_GUIDELINES.md import convention (standard → third-party → local at module level).
  3. Makes the module dependency graph visible to static analysis and readers auditing imports.

Closes #1183

Warning

⚠️ Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • index.crates.io
  • pypi.org
  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"
    - "index.crates.io"
    - "pypi.org"
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by Issue Implementer · ● 7.3M ·

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>
Copilot AI review requested due to automatic review settings May 4, 2026 11:37
@microsasa microsasa added the aw Created by agentic workflow label May 4, 2026
@microsasa microsasa enabled auto-merge May 4, 2026 11:37
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

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_summary and render_vscode_summary to module-level imports in src/copilot_usage/cli.py and 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow

Projects

None yet

2 participants