From 95ca11e98c47c3e8e57093c37134a6f51bcb6f30 Mon Sep 17 00:00:00 2001
From: Olivier Gayot <olivier.gayot@sigexec.com>
Date: Wed, 29 Dec 2021 17:05:21 +0100
Subject: Add type hinting everywhere so we can enable strict mypy options

Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
---
 swiftstory/interface/ws.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

(limited to 'swiftstory/interface')

diff --git a/swiftstory/interface/ws.py b/swiftstory/interface/ws.py
index 2485b4f..a86c730 100644
--- a/swiftstory/interface/ws.py
+++ b/swiftstory/interface/ws.py
@@ -1,6 +1,7 @@
 import contextlib
 import json
 import logging
+from typing import Union
 
 import websockets.exceptions
 from websockets.server import WebSocketServerProtocol
@@ -16,7 +17,7 @@ class WebsocketsInterface:
     def __init__(self, game_manager: GameManager):
         self.game_manager = game_manager
 
-    async def connection_handler(self, websocket: WebSocketServerProtocol, path: str):
+    async def connection_handler(self, websocket: WebSocketServerProtocol, path: str) -> None:
         client = Client(websocket, self.game_manager)
 
         with contextlib.suppress(websockets.exceptions.ConnectionClosed):
@@ -25,8 +26,8 @@ class WebsocketsInterface:
 
         client.disconnect()
 
-    def message_received_handler(self, client, message):
-        def join_game():
+    def message_received_handler(self, client: Client, message: Union[bytes, str]) -> str:
+        def join_game() -> str:
             try:
                 game_name = json_msg['game_name']
             except KeyError:
@@ -35,7 +36,7 @@ class WebsocketsInterface:
                 lang = json_msg.get('lang')
                 return client.join_game(game_name, lang)
 
-        def designate_card():
+        def designate_card() -> str:
             card_id = None
             try:
                 card_id = int(json_msg['card_id'])
@@ -44,7 +45,7 @@ class WebsocketsInterface:
             finally:
                 return client.designate_card(card_id)
 
-        def play_white_card():
+        def play_white_card() -> str:
             try:
                 card_id = int(json_msg['card_id'])
             except KeyError:
-- 
cgit v1.2.3