Skip to content

Commit 7623c35

Browse files
committed
Updated type hinting in Websocket API module to use pipe-based unions now that Python 3.9 has been dropped
1 parent c6c286e commit 7623c35

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/murfey/server/api/websocket.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
from datetime import datetime
7-
from typing import Any, TypeVar, Union
7+
from typing import Any, TypeVar
88

99
from fastapi import APIRouter, WebSocket, WebSocketDisconnect
1010
from sqlmodel import Session, select
@@ -27,7 +27,7 @@ def __init__(self):
2727
async def connect(
2828
self,
2929
websocket: WebSocket,
30-
client_id: Union[int, str],
30+
client_id: int | str,
3131
register_client: bool = True,
3232
):
3333
await websocket.accept()
@@ -48,7 +48,7 @@ def _register_new_client(client_id: int):
4848
murfey_db.commit()
4949
murfey_db.close()
5050

51-
def disconnect(self, client_id: Union[int, str], unregister_client: bool = True):
51+
def disconnect(self, client_id: int | str, unregister_client: bool = True):
5252
self.active_connections.pop(client_id)
5353
if unregister_client:
5454
murfey_db: Session = next(get_murfey_db_session())
@@ -97,7 +97,7 @@ async def websocket_endpoint(websocket: WebSocket, client_id: int):
9797
@ws.websocket("/connect/{client_id}")
9898
async def websocket_connection_endpoint(
9999
websocket: WebSocket,
100-
client_id: Union[int, str],
100+
client_id: int | str,
101101
):
102102
await manager.connect(websocket, client_id, register_client=False)
103103
await manager.broadcast(f"Client {client_id} joined")
@@ -161,7 +161,7 @@ async def close_ws_connection(client_id: int):
161161

162162

163163
@ws.delete("/connect/{client_id}")
164-
async def close_unrecorded_ws_connection(client_id: Union[int, str]):
164+
async def close_unrecorded_ws_connection(client_id: int | str):
165165
client_id_str = str(client_id).replace("\r\n", "").replace("\n", "")
166166
log.info(f"Disconnecting {client_id_str}")
167167
manager.disconnect(client_id)

0 commit comments

Comments
 (0)