diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-11-08 17:48:40 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-11-08 22:46:33 +0100 |
commit | 2696b7bc1b3c64ecdc161acd104978a8a648c376 (patch) | |
tree | a12e00463ce91466757b0883813fb5ef284a6e4c /pycameltris | |
parent | 1fe19d3e589bbc5d40b74d007d6b1984cfc34925 (diff) |
Use a nested function instead of a lambda to exit
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'pycameltris')
-rw-r--r-- | pycameltris/screens/InGame.py | 6 | ||||
-rw-r--r-- | pycameltris/screens/Pause.py | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/pycameltris/screens/InGame.py b/pycameltris/screens/InGame.py index aa3e53b..7363f5a 100644 --- a/pycameltris/screens/InGame.py +++ b/pycameltris/screens/InGame.py @@ -2,6 +2,7 @@ import contextlib from functools import partial import random import sys +from typing import NoReturn import pygame @@ -254,7 +255,10 @@ class InGame(Screen): self.screen = screen self.event_handler = dict() - self.event_handler[pygame.QUIT] = lambda _: sys.exit() + def exit(_) -> NoReturn: + sys.exit() + + self.event_handler[pygame.QUIT] = exit self.event_handler[pygame.KEYDOWN] = partial(handle_input_pressed, KeyboardController, self.players) self.event_handler[pygame.KEYUP] = partial(handle_input_released, KeyboardController, self.players) self.event_handler[pygame.JOYBUTTONDOWN] = partial(handle_input_pressed, JoystickController, self.players) diff --git a/pycameltris/screens/Pause.py b/pycameltris/screens/Pause.py index baca5ca..1502be7 100644 --- a/pycameltris/screens/Pause.py +++ b/pycameltris/screens/Pause.py @@ -1,5 +1,6 @@ import contextlib import sys +from typing import NoReturn import pygame @@ -17,7 +18,10 @@ class Pause(Screen): def __init__(self, screen): self.event_handler = dict() - self.event_handler[pygame.QUIT] = lambda _: sys.exit() + def exit(_) -> NoReturn: + sys.exit() + + self.event_handler[pygame.QUIT] = exit self.event_handler[pygame.JOYBUTTONDOWN] = lambda evt: handle_input_pressed(JoystickController(evt.joy), evt) self.event_handler[pygame.KEYDOWN] = lambda evt: handle_input_pressed(KeyboardController(pygame.key), evt) |