Skip to content

wrong type annotaions in pn.state.<callbacks> #8307

@bakkiaraj

Description

@bakkiaraj

Python version: 3.12
Panel: 1.8.3
File: .venv/lib/python3.12/site-packages/panel/io/state.py

Issue: When I do following code,

def on_session_destroyed(session_context: BokehSessionContext) -> None:
    if session_context.request is not None:
        print(f' session destroyed at the {session_context.request.uri} endpoint with session ID: {session_context.id}')
...
pn.state.on_session_destroyed(callback=on_session_destroyed) 

I get type annotation issue

Image

At run time, session_context: is BokehSessionContext type and its documented in https://panel.holoviz.org/how_to/callbacks/session.html but the code panel/io/state.py do not have correct type annotations for call backs.

Expected behavior:
Correct the callback function's type annotations.

Ex:
in state.py

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

should be

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions