Skip to content

[Python] Remove copilot.types#871

Open
brettcannon wants to merge 1 commit intogithub:mainfrom
brettcannon:types-no-more
Open

[Python] Remove copilot.types#871
brettcannon wants to merge 1 commit intogithub:mainfrom
brettcannon:types-no-more

Conversation

@brettcannon
Copy link
Contributor

Along the way, simplify copilot.__init__ to only export the high-level API.

Along the way, simplify `copilot.__init__` to only export the high-level API.
@brettcannon brettcannon requested a review from a team as a code owner March 16, 2026 23:44
Copilot AI review requested due to automatic review settings March 16, 2026 23:44
Copy link
Contributor

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

Removes the Python copilot.types module and redistributes its type definitions across the more appropriate modules (copilot.client, copilot.session, copilot.tools), while simplifying copilot.__init__ to only expose the high-level API surface.

Changes:

  • Deleted python/copilot/types.py and moved type definitions into python/copilot/client.py, python/copilot/session.py, and python/copilot/tools.py.
  • Simplified python/copilot/__init__.py exports to only include CopilotClient, CopilotSession, connection configs, and define_tool.
  • Updated imports across scenarios, tests, samples, and docs to use the new module locations.

Reviewed changes

Copilot reviewed 67 out of 67 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/scenarios/transport/tcp/python/main.py Update imports to new type locations.
test/scenarios/transport/stdio/python/main.py Update imports to new type locations.
test/scenarios/transport/reconnect/python/main.py Update imports to new type locations.
test/scenarios/tools/virtual-filesystem/python/main.py Update imports to new type locations.
test/scenarios/tools/tool-overrides/python/main.py Update imports to new type locations.
test/scenarios/tools/tool-filtering/python/main.py Update imports to new type locations.
test/scenarios/tools/skills/python/main.py Update imports to new type locations.
test/scenarios/tools/no-tools/python/main.py Update imports to new type locations.
test/scenarios/tools/mcp-servers/python/main.py Update imports to new type locations.
test/scenarios/tools/custom-agents/python/main.py Update imports to new type locations.
test/scenarios/sessions/streaming/python/main.py Update imports to new type locations.
test/scenarios/sessions/session-resume/python/main.py Update imports to new type locations.
test/scenarios/sessions/infinite-sessions/python/main.py Update imports to new type locations.
test/scenarios/sessions/concurrent-sessions/python/main.py Update imports to new type locations.
test/scenarios/prompts/system-message/python/main.py Update imports to new type locations.
test/scenarios/prompts/reasoning-effort/python/main.py Update imports to new type locations.
test/scenarios/prompts/attachments/python/main.py Update imports to new type locations.
test/scenarios/modes/minimal/python/main.py Update imports to new type locations.
test/scenarios/modes/default/python/main.py Update imports to new type locations.
test/scenarios/callbacks/user-input/python/main.py Update imports to new type locations.
test/scenarios/callbacks/permissions/python/main.py Update imports to new type locations.
test/scenarios/callbacks/hooks/python/main.py Update imports to new type locations.
test/scenarios/bundling/fully-bundled/python/main.py Update imports to new type locations.
test/scenarios/bundling/container-proxy/python/main.py Update imports to new type locations.
test/scenarios/bundling/app-direct-server/python/main.py Update imports to new type locations.
test/scenarios/bundling/app-backend-to-server/python/main.py Update imports to new type locations.
test/scenarios/auth/gh-app/python/main.py Update imports to new type locations.
test/scenarios/auth/byok-openai/python/main.py Update imports to new type locations.
test/scenarios/auth/byok-ollama/python/main.py Update imports to new type locations.
test/scenarios/auth/byok-azure/python/main.py Update imports to new type locations.
test/scenarios/auth/byok-anthropic/python/main.py Update imports to new type locations.
python/test_telemetry.py Import Telemetry/Subprocess config types from copilot.client.
python/test_client.py Update imports to copilot.client / copilot.session; stop using copilot.types.
python/samples/chat.py Import PermissionHandler from copilot.session.
python/e2e/testharness/context.py Import SubprocessConfig from copilot.client.
python/e2e/test_tools_unit.py Import tool types directly from copilot.tools.
python/e2e/test_tools.py Import session/tool types from their new modules.
python/e2e/test_streaming_fidelity.py Import session/client types from their new modules.
python/e2e/test_skills.py Import PermissionHandler from copilot.session.
python/e2e/test_session.py Import Tool/ToolResult from copilot.tools; session types from copilot.session.
python/e2e/test_rpc.py Import SubprocessConfig from copilot.client and PermissionHandler from copilot.session.
python/e2e/test_permissions.py Import permission types from copilot.session.
python/e2e/test_multi_client.py Import session/tool/client types from their new modules.
python/e2e/test_mcp_and_agents.py Import MCP/agent/session types from copilot.session.
python/e2e/test_hooks.py Import PermissionHandler from copilot.session.
python/e2e/test_compaction.py Import PermissionHandler from copilot.session.
python/e2e/test_client.py Import StopError/SubprocessConfig from copilot.client; permission handler from copilot.session.
python/e2e/test_ask_user.py Import PermissionHandler from copilot.session.
python/e2e/test_agent_and_compact_rpc.py Import SubprocessConfig from copilot.client; permission handler from copilot.session.
python/copilot/types.py Removed legacy centralized types module.
python/copilot/tools.py Inlines Tool-related dataclasses previously in copilot.types.
python/copilot/session.py Inlines session-related config/handler/attachment types previously in copilot.types.
python/copilot/client.py Inlines client/connection/config/model/metadata types previously in copilot.types.
python/copilot/init.py Restricts root exports to high-level API and connection configs.
python/README.md Update Tool import to copilot.tools.
docs/setup/azure-managed-identity.md Update Provider/Session config imports to copilot.session.
docs/hooks/user-prompt-submitted.md Update type imports to copilot.session (but Python snippet still references HookInvocation).
docs/hooks/session-lifecycle.md Update type imports to copilot.session (but Python snippets still reference HookInvocation / mismatched return types).
docs/hooks/pre-tool-use.md Update type imports to copilot.session (but Python snippet still references HookInvocation).
docs/hooks/post-tool-use.md Update type imports to copilot.session (but Python snippet still references HookInvocation).
docs/hooks/error-handling.md Update type imports to copilot.session (but Python snippet still references HookInvocation).
docs/getting-started.md Update PermissionHandler import to copilot.session.
docs/features/steering-and-queueing.md Update PermissionRequestResult import to copilot.session.
docs/features/skills.md Update PermissionRequestResult import to copilot.session.
docs/features/image-input.md Update PermissionRequestResult import to copilot.session.
docs/features/custom-agents.md Update PermissionRequestResult import to copilot.session.
docs/auth/byok.md Update model-type imports to copilot.client.
Comments suppressed due to low confidence (6)

docs/hooks/user-prompt-submitted.md:44

  • In the Python hook signature snippet, HookInvocation is referenced but is no longer imported/defined after switching away from copilot.types. This will make the docs-validated code block fail. Either import a HookInvocation alias (e.g., from copilot.session if added) or update the signature to use the actual invocation type used by the SDK (currently a dict[str, str]).
from copilot.session import UserPromptSubmittedHookInput, UserPromptSubmittedHookOutput
from typing import Callable, Awaitable

UserPromptSubmittedHandler = Callable[
    [UserPromptSubmittedHookInput, HookInvocation],
    Awaitable[UserPromptSubmittedHookOutput | None]
]

docs/hooks/pre-tool-use.md:44

  • The Python docs-validated snippet still uses HookInvocation in the handler type but it is no longer imported/defined after the import change. This will break docs validation; either define HookInvocation locally (or export it from copilot.session) or change the signature to the SDK’s invocation type (dict[str, str]).
from copilot.session import PreToolUseHookInput, PreToolUseHookOutput
from typing import Callable, Awaitable

PreToolUseHandler = Callable[
    [PreToolUseHookInput, HookInvocation],
    Awaitable[PreToolUseHookOutput | None]
]

docs/hooks/post-tool-use.md:44

  • The Python hook signature references HookInvocation but it is no longer imported/defined after switching the import to copilot.session. This makes the docs-validated code block invalid; import/define HookInvocation (or use dict[str, str] to match the SDK).
from copilot.session import PostToolUseHookInput, PostToolUseHookOutput
from typing import Callable, Awaitable

PostToolUseHandler = Callable[
    [PostToolUseHookInput, HookInvocation],
    Awaitable[PostToolUseHookOutput | None]
]

docs/hooks/error-handling.md:44

  • The Python hook signature still uses HookInvocation, but the updated import line no longer imports it (and it isn’t defined in the snippet). This will fail docs validation; either add/define HookInvocation or update the signature to use the actual invocation type (dict[str, str]).
from copilot.session import ErrorOccurredHookInput, ErrorOccurredHookOutput
from typing import Callable, Awaitable

ErrorOccurredHandler = Callable[
    [ErrorOccurredHookInput, HookInvocation],
    Awaitable[ErrorOccurredHookOutput | None]
]

docs/hooks/session-lifecycle.md:48

  • In the Python SessionStart handler snippet, HookInvocation is referenced but not imported/defined after the import change. This will break docs validation; either import/define a HookInvocation alias or update the signature to use dict[str, str] (which matches the SDK’s hook invocation parameter).
from copilot.session import SessionStartHookInput, SessionStartHookOutput
from typing import Callable, Awaitable

SessionStartHandler = Callable[
    [SessionStartHookInput, HookInvocation],
    Awaitable[SessionStartHookOutput | None]
]

docs/hooks/session-lifecycle.md:265

  • In the Python SessionEnd handler snippet, HookInvocation (and SessionEndHookOutput in the visible block) are referenced but not imported/defined. Additionally, the hidden and visible blocks show different return types. This is likely to fail docs validation; align both blocks and ensure all referenced types are imported/defined (or use dict[str, str] for the invocation parameter).
from copilot.session import SessionEndHookInput
from typing import Callable, Awaitable

SessionEndHandler = Callable[
    [SessionEndHookInput, HookInvocation],
    Awaitable[None]
]
SessionEndHandler = Callable[
    [SessionEndHookInput, HookInvocation],
    Awaitable[SessionEndHookOutput | None]
]

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants