Skip to content

Conversation

@philippjfr
Copy link
Member

Fixes #8307

Copilot AI review requested due to automatic review settings December 2, 2025 11:20
Copilot finished reviewing on behalf of philippjfr December 2, 2025 11:23
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

This PR attempts to fix type annotations for session lifecycle callbacks by changing the parameter type from SessionContext to BokehSessionContext in two public methods: on_session_created and on_session_destroyed.

Key Changes

  • Updated type annotation for on_session_created callback parameter from SessionContext to BokehSessionContext
  • Updated type annotation for on_session_destroyed callback parameter from SessionContext to BokehSessionContext

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

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

self._on_session_created.append(callback)

def on_session_destroyed(self, callback: Callable[[SessionContext], None]) -> None:
def on_session_destroyed(self, callback: Callable[[BokehSessionContext], None]) -> None:
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The type annotation change to BokehSessionContext is inconsistent with the class variable _on_session_destroyed at line 189, which is typed as list[Callable[[SessionContext], None]]. This creates a type incompatibility when appending callbacks at line 808. Additionally, Bokeh's Document.on_session_destroyed method (called at line 804) expects Callable[[SessionContext], None], not BokehSessionContext.

The class variable at line 189 should also be updated to use BokehSessionContext for consistency, or if SessionContext is the correct type, then this change should be reverted.

Suggested change
def on_session_destroyed(self, callback: Callable[[BokehSessionContext], None]) -> None:
def on_session_destroyed(self, callback: Callable[[SessionContext], None]) -> None:

Copilot uses AI. Check for mistakes.
self._onload[self.curdoc] = [(callback, threaded)]

def on_session_created(self, callback: Callable[[SessionContext], None]) -> None:
def on_session_created(self, callback: Callable[[BokehSessionContext], None]) -> None:
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The type annotation change to BokehSessionContext is inconsistent with the class variable _on_session_created at line 187, which is typed as list[Callable[[SessionContext], None]]. This creates a type incompatibility when appending callbacks at line 796. Additionally, internal callbacks like _initialize_session_info (line 167 in server.py) and _register_session_destroyed (line 501) use SessionContext, not BokehSessionContext.

The class variables at lines 187-189 should also be updated to use BokehSessionContext for consistency, or if SessionContext is the correct type, then this change should be reverted.

Suggested change
def on_session_created(self, callback: Callable[[BokehSessionContext], None]) -> None:
def on_session_created(self, callback: Callable[[SessionContext], None]) -> None:

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.39%. Comparing base (b0e7457) to head (56478c8).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8320       +/-   ##
===========================================
+ Coverage   70.21%   85.39%   +15.17%     
===========================================
  Files         347      348        +1     
  Lines       54596    54597        +1     
===========================================
+ Hits        38337    46624     +8287     
+ Misses      16259     7973     -8286     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

wrong type annotaions in pn.state.<callbacks>

2 participants