From 7779e857e040733e04c95ab0b129693170df4db8 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 8 Nov 2021 22:17:14 +0100 Subject: Add type hints for screen package Signed-off-by: Olivier Gayot --- pycameltris/screens/Pause.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'pycameltris/screens/Pause.py') diff --git a/pycameltris/screens/Pause.py b/pycameltris/screens/Pause.py index 1502be7..885b7f6 100644 --- a/pycameltris/screens/Pause.py +++ b/pycameltris/screens/Pause.py @@ -1,22 +1,22 @@ import contextlib import sys -from typing import NoReturn +from typing import Callable, NoReturn import pygame from .Screen import Screen -from ..controller import KeyboardController, JoystickController, Input +from ..controller import Controller, KeyboardController, JoystickController, Input from ..misc import UnPause -def handle_input_pressed(controller, event): +def handle_input_pressed(controller: Controller, event: pygame.event.Event): if controller.get_input_down(event) == Input.PAUSE: raise UnPause() class Pause(Screen): - def __init__(self, screen): - self.event_handler = dict() + def __init__(self, screen: pygame.Surface): + self.event_handler: dict[int, Callable[[pygame.event.Event], None]] = {} def exit(_) -> NoReturn: sys.exit() @@ -26,10 +26,10 @@ class Pause(Screen): self.event_handler[pygame.KEYDOWN] = lambda evt: handle_input_pressed(KeyboardController(pygame.key), evt) - def refresh(self): + def refresh(self) -> None: pass - def oneframe(self): + def oneframe(self) -> None: try: for event in pygame.event.get(): with contextlib.suppress(KeyError): -- cgit v1.2.3