Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Oct 14, 2024
1 parent 080e51a commit 218179b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions projects/jupyter-server-ydoc/jupyter_server_ydoc/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time
import uuid
from logging import Logger
from typing import Any
from typing import Any, Literal
from uuid import uuid4

from jupyter_server.auth import authorized
Expand Down Expand Up @@ -384,15 +384,17 @@ async def _clean_room(self) -> None:
self._emit(LogLevel.INFO, "clean", "Loader deleted.")
del self._room_locks[self._room_id]

def _on_global_awareness_event(self, topic: str, changes: tuple[dict[str, Any], Any]) -> None:
def _on_global_awareness_event(
self, topic: Literal["change", "update"], changes: tuple[dict[str, Any], Any]
) -> None:
"""
Update the users when the global awareness changes.
Parameters:
topic (str): `"update"` or `"change"` (`"change"` is triggered only if the states are modified).
changes (tuple[dict[str, Any], Any]): The changes and the origin of the changes.
"""
if type != "change":
if topic != "change":
return
added_users = changes[0]["added"]
removed_users = changes[0]["removed"]
Expand Down

0 comments on commit 218179b

Please sign in to comment.