Skip to content

Conversation

@harupy
Copy link
Contributor

@harupy harupy commented Jan 24, 2026

Add SessionEvent type hints to on_event callback functions in the Python SDK README examples for better IDE support and documentation clarity.


This PR was filed by Copilot CLI.

@harupy harupy requested a review from a team as a code owner January 24, 2026 10:32
Copilot AI review requested due to automatic review settings January 24, 2026 10:32
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

Updates the Python SDK README examples to annotate on_event callbacks with the SessionEvent type for better IDE/type-checker support.

Changes:

  • Import SessionEvent alongside CopilotClient in README examples.
  • Add SessionEvent type annotations to on_event callback parameters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

session = await client.create_session({"model": "gpt-5"})

def on_event(event):
def on_event(event: SessionEvent):
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This README code block now annotates event as SessionEvent, but the snippet doesn't import SessionEvent (or qualify it), so copy/pasting just this block will raise NameError. Consider adding from copilot import SessionEvent within the same code block (or dropping the annotation in this snippet if you want it import-free).

Copilot uses AI. Check for mistakes.

def on_event(event):
def on_event(event: SessionEvent):
print(f"Event: {event['type']}")
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With event: SessionEvent, event['type'] is incorrect because SessionEvent is a dataclass and isn't subscriptable. This example should use event.type (or event.type.value) to print the event type.

Suggested change
print(f"Event: {event['type']}")
print(f"Event: {event.type.value}")

Copilot uses AI. Check for mistakes.
@harupy harupy closed this Jan 24, 2026
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.

1 participant