From 15afcda17766968f420d53b885f8eca0cf3b40a7 Mon Sep 17 00:00:00 2001 From: Jan Kantert Date: Wed, 15 Mar 2017 16:02:26 +0100 Subject: [PATCH] more type annotations and fixes --- mpf/assets/show.py | 2 +- mpf/config_players/event_player.py | 1 - mpf/config_players/random_event_player.py | 1 - mpf/core/assets.py | 11 +++- mpf/core/config_validator.py | 8 ++- mpf/core/device.py | 32 ++++++++---- mpf/core/logic_blocks.py | 15 +++--- mpf/core/machine.py | 50 ++++++++---------- mpf/core/mode.py | 16 +++--- mpf/core/mode_controller.py | 4 +- mpf/core/switch_controller.py | 10 ++-- .../ball_device/outgoing_balls_handler.py | 4 +- mpf/devices/switch.py | 13 +++-- mpf/migrator/migrator.py | 4 +- mpf/modes/service/code/service.py | 4 +- mpf/modes/tilt/code/tilt.py | 19 ++++--- mpf/platforms/opp/opp.py | 51 ++++++++++++------- mpf/tests/test_ConfigPlayers.py | 3 +- mpf/tests/test_CreditsMode.py | 5 -- 19 files changed, 146 insertions(+), 107 deletions(-) diff --git a/mpf/assets/show.py b/mpf/assets/show.py index 5b68ecb82..9fef39c5a 100644 --- a/mpf/assets/show.py +++ b/mpf/assets/show.py @@ -32,7 +32,7 @@ class Show(Asset): path_string = 'shows' config_section = 'shows' disk_asset_section = 'file_shows' - extensions = 'yaml' + extensions = tuple('yaml') class_priority = 100 pool_config_section = 'show_pools' asset_group_class = ShowPool diff --git a/mpf/config_players/event_player.py b/mpf/config_players/event_player.py index 5dcb480ee..0874bdead 100644 --- a/mpf/config_players/event_player.py +++ b/mpf/config_players/event_player.py @@ -11,7 +11,6 @@ class EventPlayer(FlatConfigPlayer): config_file_section = 'event_player' show_section = 'events' - device_collection = None def __init__(self, machine): """Initialise EventPlayer.""" diff --git a/mpf/config_players/random_event_player.py b/mpf/config_players/random_event_player.py index 202dad6b4..4af20be03 100644 --- a/mpf/config_players/random_event_player.py +++ b/mpf/config_players/random_event_player.py @@ -10,7 +10,6 @@ class RandomEventPlayer(ConfigPlayer): config_file_section = 'random_event_player' show_section = 'random_events' - device_collection = None def __init__(self, machine): """Initialise random event player.""" diff --git a/mpf/core/assets.py b/mpf/core/assets.py index b9b44f1e1..168124fe6 100644 --- a/mpf/core/assets.py +++ b/mpf/core/assets.py @@ -7,6 +7,8 @@ import asyncio +from typing import Iterable + from mpf.core.case_insensitive_dict import CaseInsensitiveDict from mpf.core.mpf_controller import MpfController from mpf.core.utility_functions import Util @@ -763,9 +765,14 @@ class Asset(object): path_string = '' # entry from mpf-mc:paths: for asset folder name config_section = '' # section in the config files for this asset disk_asset_section = '' # option is assets: config name is different - extensions = ('', '', '') # tuple of strings, no dots + + # tuple of strings, no dots + extensions = tuple() # type: Iterable[str] class_priority = 0 # Order asset classes will be loaded. Higher is first. - pool_config_section = None # Create an associated AssetPool instance + + # Create an associated AssetPool instance + pool_config_section = None # type: str + asset_group_class = AssetPool # replace with your own asset group class @classmethod diff --git a/mpf/core/config_validator.py b/mpf/core/config_validator.py index 3b3e58174..3bced1e68 100644 --- a/mpf/core/config_validator.py +++ b/mpf/core/config_validator.py @@ -3,6 +3,9 @@ import re from copy import deepcopy +from typing import Any +from typing import Dict + from mpf.core.config_spec import mpf_config_spec from mpf.core.rgb_color import named_rgb_colors, RGBColor from mpf.exceptions.ConfigFileError import ConfigFileError @@ -11,14 +14,15 @@ from mpf.core.case_insensitive_dict import CaseInsensitiveDict -# log = logging.getLogger('ConfigValidator') +# TODO: improve this +ConfigDict = Dict[str, Any] class ConfigValidator(object): """Validates config against config specs.""" - config_spec = None + config_spec = None # type: ConfigDict def __init__(self, machine): """Initialise validator.""" diff --git a/mpf/core/device.py b/mpf/core/device.py index a77d2a822..acf0513c7 100644 --- a/mpf/core/device.py +++ b/mpf/core/device.py @@ -1,20 +1,34 @@ """Contains the Device base class.""" import abc +from typing import List +from typing import TYPE_CHECKING + from mpf.core.machine import MachineController from mpf.core.logging import LogMixin +if TYPE_CHECKING: + from mpf.core.config_validator import ConfigDict + from mpf.core.platform import BasePlatform + class Device(LogMixin, metaclass=abc.ABCMeta): """Generic parent class of for every hardware device in a pinball machine.""" - config_section = None # String of the config section name - collection = None # String name of the collection - class_label = None # String of the friendly name of the device class - allow_empty_configs = False # Can a config for this device be empty? + # String of the config section name + config_section = None # type: str + + # String name of the collection + collection = None # type: str + + # String of the friendly name of the device class + class_label = None # type: str + + # Can a config for this device be empty? + allow_empty_configs = False - def __init__(self, machine: MachineController, name: str): + def __init__(self, machine: MachineController, name: str) -> None: """Set up default attributes of every device. Args: @@ -24,10 +38,10 @@ def __init__(self, machine: MachineController, name: str): super().__init__() self.machine = machine self.name = name.lower() - self.tags = [] - self.label = None - self.platform = None - self.config = dict() + self.tags = [] # type: List[str] + self.label = None # type: str + self.platform = None # type: BasePlatform + self.config = dict() # type: ConfigDict @classmethod def get_config_spec(cls): diff --git a/mpf/core/logic_blocks.py b/mpf/core/logic_blocks.py index 4c0b2f47e..9efe134c5 100755 --- a/mpf/core/logic_blocks.py +++ b/mpf/core/logic_blocks.py @@ -3,7 +3,10 @@ import copy import logging +from typing import Set + from mpf.core.delays import DelayManager +from mpf.core.events import EventHandlerKey from mpf.core.machine import MachineController from mpf.core.mode import Mode from mpf.core.player import Player @@ -16,7 +19,7 @@ class LogicBlocks(MpfController): """LogicBlock Manager.""" - def __init__(self, machine: MachineController): + def __init__(self, machine: MachineController) -> None: """Initialize LogicBlock manager.""" super().__init__(machine) @@ -103,7 +106,7 @@ def _process_config(self, config: dict, mode: Mode, priority: int=0): def _create_logic_blocks(self, config: dict, player: Player): # config is localized for LogicBlock - blocks_added = set() + blocks_added = set() # type: Set[LogicBlock] if 'counters' in config: for item in config['counters']: @@ -138,13 +141,13 @@ class LogicBlock(LogMixin): """Parent class for each of the logic block classes.""" - def __init__(self, machine: MachineController, name: str, player: Player, config: dict): + def __init__(self, machine: MachineController, name: str, player: Player, config: dict) -> None: """Initialize logic block.""" super().__init__() self.machine = machine self.name = name self.player = player - self.handler_keys = set() + self.handler_keys = set() # type: Set[EventHandlerKey] # LogicBlocks are loaded multiple times and config_validator changes the config # therefore we have to copy the config @@ -403,7 +406,7 @@ def config_section_name(self): """Return config section.""" return 'counter' - def __init__(self, machine: MachineController, name: str, player: Player, config: dict): + def __init__(self, machine: MachineController, name: str, player: Player, config: dict) -> None: """Initialise counter.""" if 'events_when_hit' not in config: # for compatibility post the same default as previously for @@ -611,7 +614,7 @@ def config_section_name(self): """Return config section.""" return "sequence" - def __init__(self, machine: MachineController, name: str, player: Player, config: dict): + def __init__(self, machine: MachineController, name: str, player: Player, config: dict) -> None: """Initialise sequence.""" super().__init__(machine, name, player, config) diff --git a/mpf/core/machine.py b/mpf/core/machine.py index 367c47ae9..e08ffdd00 100644 --- a/mpf/core/machine.py +++ b/mpf/core/machine.py @@ -7,16 +7,17 @@ import pickle import tempfile -import queue import sys import threading from pkg_resources import iter_entry_points +from typing import Any, TYPE_CHECKING, Callable, Dict, List, Set from mpf._version import __version__ from mpf.core.case_insensitive_dict import CaseInsensitiveDict from mpf.core.clock import ClockBase from mpf.core.config_processor import ConfigProcessor +from mpf.core.config_validator import ConfigDict from mpf.core.config_validator import ConfigValidator from mpf.core.data_manager import DataManager from mpf.core.delays import DelayManager, DelayManagerRegistry @@ -24,6 +25,12 @@ from mpf.core.utility_functions import Util from mpf.core.logging import LogMixin +if TYPE_CHECKING: + from mpf.modes.game.code.game import Game + from mpf.core.events import EventManager + from mpf.core.scriptlet import Scriptlet + from mpf.core.platform import BasePlatform + # pylint: disable-msg=too-many-instance-attributes class MachineController(LogMixin): @@ -51,7 +58,7 @@ class MachineController(LogMixin): """ - def __init__(self, mpf_path: str, machine_path: str, options: dict): + def __init__(self, mpf_path: str, machine_path: str, options: dict) -> None: """Initialize machine controller.""" super().__init__() self.log = logging.getLogger("Machine") @@ -67,35 +74,32 @@ def __init__(self, mpf_path: str, machine_path: str, options: dict): self.machine_path = machine_path self.verify_system_info() - self._exception = None + self._exception = None # type: Any - self._boot_holds = set() + self._boot_holds = set() # type: Set[str] self.is_init_done = False self.register_boot_hold('init') self._done = False - self.monitors = dict() - self.plugins = list() - self.scriptlets = list() + self.monitors = dict() # type: Dict[str, Set[Callable]] + self.plugins = list() # type: List[Any] + self.scriptlets = list() # type: List[Scriptlet] self.modes = DeviceCollection(self, 'modes', None) - self.game = None - self.active_debugger = dict() + self.game = None # type: Game self.machine_vars = CaseInsensitiveDict() self.machine_var_monitor = False - self.machine_var_data_manager = None + self.machine_var_data_manager = None # type: DataManager self.thread_stopper = threading.Event() - self.crash_queue = queue.Queue() - - self.config = None - self.events = None + self.config = None # type: ConfigDict + self.events = None # type: EventManager self._set_machine_path() self.config_validator = ConfigValidator(self) self._load_config() - self.machine_config = self.config + self.machine_config = self.config # type: ConfigDict self.configure_logging( 'Machine', self.config['logging']['console']['machine_controller'], @@ -105,10 +109,9 @@ def __init__(self, mpf_path: str, machine_path: str, options: dict): self.delay = DelayManager(self.delayRegistry) self.clock = self._load_clock() - self._crash_queue_checker = self.clock.schedule_interval(self._check_crash_queue, 1) - self.hardware_platforms = dict() - self.default_platform = None + self.hardware_platforms = dict() # type: Dict[str, BasePlatform] + self.default_platform = None # type: BasePlatform self._load_hardware_platforms() @@ -277,17 +280,6 @@ def _load_machine_vars(self): self.create_machine_var(name=name, value=settings['value']) - def _check_crash_queue(self, time): - del time - try: - crash = self.crash_queue.get(block=False) - except queue.Empty: - pass - else: - print("MPF Shutting down due to child thread crash") - print("Crash details: %s", crash) - self.stop() - def _set_machine_path(self): # Add the machine folder to sys.path so we can import modules from it sys.path.insert(0, self.machine_path) diff --git a/mpf/core/mode.py b/mpf/core/mode.py index 1d2135417..858f64d96 100755 --- a/mpf/core/mode.py +++ b/mpf/core/mode.py @@ -5,6 +5,7 @@ from typing import Callable from typing import Dict from typing import List +from typing import Set from typing import Tuple from mpf.core.case_insensitive_dict import CaseInsensitiveDict @@ -12,6 +13,7 @@ from mpf.core.device import Device from mpf.core.events import EventHandlerKey from mpf.core.events import QueuedEvent +from mpf.core.player import Player from mpf.core.switch_controller import SwitchHandler from mpf.core.timer import Timer @@ -46,18 +48,18 @@ def __init__(self, machine, config: dict, name: str, path) -> None: self._mode_start_wait_queue = None # type: QueuedEvent self.stop_methods = list() # type: List[Tuple[Callable, Any]] self.timers = dict() # type: Dict[str, Timer] - self.start_callback = None # type: Callable - self.stop_callback = None # type: Callable - self.event_handlers = set() # type: List[EventHandlerKey] + self.start_callback = None # type: callable + self.stop_callback = None # type: callable + self.event_handlers = set() # type: Set[EventHandlerKey] self.switch_handlers = list() # type: List[SwitchHandler] self.mode_stop_kwargs = dict() # type: Dict[str, Any] - self.mode_devices = set() # type: List[Device] - self.start_event_kwargs = None + self.mode_devices = set() # type: Set[Device] + self.start_event_kwargs = None # type: Dict[str, Any] self.stopping = False self.delay = DelayManager(self.machine.delayRegistry) - self.player = None + self.player = None # type: Player '''Reference to the current player object.''' self._validate_mode_config() @@ -552,7 +554,7 @@ def _setup_timers(self): for timer, settings in self.config['timers'].items(): self.timers[timer] = Timer(machine=self.machine, mode=self, - name=timer, config=settings) + name=timer, config=settings) return self._kill_timers diff --git a/mpf/core/mode_controller.py b/mpf/core/mode_controller.py index 13d1a2f01..a3a185c24 100644 --- a/mpf/core/mode_controller.py +++ b/mpf/core/mode_controller.py @@ -7,9 +7,7 @@ from mpf.core.utility_functions import Util from mpf.core.mpf_controller import MpfController -RemoteMethod = namedtuple('RemoteMethod', - 'method config_section kwargs priority', - verbose=False) +RemoteMethod = namedtuple('RemoteMethod', ['method', 'config_section', 'kwargs', 'priority']) """RemotedMethod is used by other modules that want to register a method to be called on mode_start or mode_stop. diff --git a/mpf/core/switch_controller.py b/mpf/core/switch_controller.py index 7b3523c38..778564806 100644 --- a/mpf/core/switch_controller.py +++ b/mpf/core/switch_controller.py @@ -10,6 +10,8 @@ import asyncio from functools import partial +from typing import List + from mpf.core.case_insensitive_dict import CaseInsensitiveDict from mpf.core.mpf_controller import MpfController from mpf.core.utility_functions import Util @@ -397,9 +399,9 @@ def wait_for_switch(self, switch_name: str, state: int=1, only_on_change=True, m """Wait for a switch to change into state.""" return self.wait_for_any_switch([switch_name], state, only_on_change, ms) - def wait_for_any_switch(self, switch_names: [str], state: int=1, only_on_change=True, ms=0): + def wait_for_any_switch(self, switch_names: List[str], state: int=1, only_on_change=True, ms=0): """Wait for the first switch in the list to change into state.""" - future = asyncio.Future(loop=self.machine.clock.loop) + future = asyncio.Future(loop=self.machine.clock.loop) # type: asyncio.Future if not only_on_change: for switch_name in switch_names: @@ -407,7 +409,7 @@ def wait_for_any_switch(self, switch_names: [str], state: int=1, only_on_change= future.set_result({"switch_name": switch_name, "state": state, "ms": ms}) return future - handlers = [] + handlers = [] # type: List[SwitchHandler] future.add_done_callback(partial(self._future_done, handlers)) for switch_name in switch_names: handlers.append(self.add_switch_handler(switch_name, state=state, ms=ms, @@ -417,7 +419,7 @@ def wait_for_any_switch(self, switch_names: [str], state: int=1, only_on_change= switch_name=switch_name))) return future - def _future_done(self, handlers, future): + def _future_done(self, handlers: List[SwitchHandler], future: asyncio.Future): del future for handler in handlers: self.remove_switch_handler_by_key(handler) diff --git a/mpf/devices/ball_device/outgoing_balls_handler.py b/mpf/devices/ball_device/outgoing_balls_handler.py index 5bfc63159..75565de95 100644 --- a/mpf/devices/ball_device/outgoing_balls_handler.py +++ b/mpf/devices/ball_device/outgoing_balls_handler.py @@ -416,8 +416,9 @@ def _handle_late_confirm_or_missing(self, eject_request: OutgoingBall, ball_ejec # if target is playfield mark eject as confirmed self.debug_log("Confirming eject because target is playfield and ball did not return.") incoming_ball_at_target.ball_arrived() + yield from self._handle_eject_success(ball_eject_process, eject_request) + return True - # TODO: timeout try: event = yield from Util.first([ball_return_future, unknown_balls_future, eject_success_future], timeout=timeout, loop=self.machine.clock.loop) @@ -444,6 +445,7 @@ def _handle_late_confirm_or_missing(self, eject_request: OutgoingBall, ball_ejec self.debug_log("Got unknown balls. Assuming a ball returned.") incoming_ball_at_target.did_not_arrive() ball_eject_process.ball_returned() + return False else: raise AssertionError("Invalid state") diff --git a/mpf/devices/switch.py b/mpf/devices/switch.py index c18e8c07c..9417d097a 100644 --- a/mpf/devices/switch.py +++ b/mpf/devices/switch.py @@ -1,9 +1,12 @@ """Contains the Switch parent class.""" import copy +from typing import Set + from mpf.core.device_monitor import DeviceMonitor from mpf.core.machine import MachineController from mpf.core.system_wide_device import SystemWideDevice +from mpf.platforms.interfaces.switch_platform_interface import SwitchPlatformInterface @DeviceMonitor("state", "recycle_jitter_count") @@ -15,13 +18,13 @@ class Switch(SystemWideDevice): collection = 'switches' class_label = 'switch' - def __init__(self, machine: MachineController, name): + def __init__(self, machine: MachineController, name: str) -> None: """Initialise switch.""" - self.hw_switch = None + self.hw_switch = None # type: SwitchPlatformInterface super().__init__(machine, name) - self.deactivation_events = set() - self.activation_events = set() + self.deactivation_events = set() # type: Set[str] + self.activation_events = set() # type: Set[str] self.state = 0 """ The logical state of a switch. 1 = active, 0 = inactive. This takes into consideration the NC or NO settings for the switch.""" @@ -36,7 +39,7 @@ def __init__(self, machine: MachineController, name): self.recycle_clear_time = 0 self.recycle_jitter_count = 0 - self._configured_switch = None + self._configured_switch = None # type: ReconfiguredSwitch # register switch so other devices can add handlers to it self.machine.switch_controller.register_switch(name) diff --git a/mpf/migrator/migrator.py b/mpf/migrator/migrator.py index 21a75472f..a6c217974 100644 --- a/mpf/migrator/migrator.py +++ b/mpf/migrator/migrator.py @@ -156,8 +156,8 @@ class VersionMigrator(object): renames = '' moves = '' additions = '' - migration_logger = None - config_version = None + migration_logger = None # type: logging.Logger + config_version = None # type: int log = logging.getLogger('Migrator') def __init__(self, file_name, file_contents): diff --git a/mpf/modes/service/code/service.py b/mpf/modes/service/code/service.py index 41e08518d..9e9f21b74 100644 --- a/mpf/modes/service/code/service.py +++ b/mpf/modes/service/code/service.py @@ -2,6 +2,8 @@ import asyncio from collections import namedtuple +from typing import List + from mpf.core.async_mode import AsyncMode from mpf.core.switch_controller import MonitoredSwitchChange from mpf.core.utility_functions import Util @@ -70,7 +72,7 @@ def _start_main_menu(self): self._service_mode_exit() - def _update_main_menu(self, items: [ServiceMenuEntry], position: int): + def _update_main_menu(self, items: List[ServiceMenuEntry], position: int): self.machine.events.post("service_menu_deselected") self.machine.events.post("service_menu_show") self.machine.events.post("service_menu_selected_{}".format(items[position].label)) diff --git a/mpf/modes/tilt/code/tilt.py b/mpf/modes/tilt/code/tilt.py index 8519f1e7b..a0b261359 100644 --- a/mpf/modes/tilt/code/tilt.py +++ b/mpf/modes/tilt/code/tilt.py @@ -1,4 +1,9 @@ """Contains the Tilt mode code.""" +from typing import Set + +from mpf.core.config_validator import ConfigDict +from mpf.core.events import EventHandlerKey +from mpf.core.events import QueuedEvent from mpf.core.machine import MachineController from mpf.core.mode import Mode @@ -7,14 +12,14 @@ class Tilt(Mode): """A mode which handles a tilt in a pinball machine.""" - def __init__(self, machine: MachineController, config: dict, name: str, path): + def __init__(self, machine: MachineController, config: dict, name: str, path) -> None: """Create mode.""" - self._balls_to_collect = None - self._last_warning = None - self.ball_ending_tilted_queue = None - self.tilt_event_handlers = None - self.last_tilt_warning_switch = None - self.tilt_config = None + self._balls_to_collect = None # type: int + self._last_warning = None # type: int + self.ball_ending_tilted_queue = None # type: QueuedEvent + self.tilt_event_handlers = None # type: Set[EventHandlerKey] + self.last_tilt_warning_switch = None # type: int + self.tilt_config = None # type: ConfigDict super().__init__(machine, config, name, path) def mode_init(self): diff --git a/mpf/platforms/opp/opp.py b/mpf/platforms/opp/opp.py index b08e589a7..363551637 100644 --- a/mpf/platforms/opp/opp.py +++ b/mpf/platforms/opp/opp.py @@ -8,11 +8,16 @@ import asyncio from typing import Dict +from typing import List +from typing import Set from mpf.platforms.base_serial_communicator import BaseSerialCommunicator +from mpf.platforms.opp.opp_coil import OPPSolenoid from mpf.platforms.opp.opp_coil import OPPSolenoidCard +from mpf.platforms.opp.opp_incand import OPPIncand from mpf.platforms.opp.opp_incand import OPPIncandCard +from mpf.platforms.opp.opp_neopixel import OPPNeopixel from mpf.platforms.opp.opp_neopixel import OPPNeopixelCard from mpf.platforms.opp.opp_switch import OPPInputCard from mpf.platforms.opp.opp_rs232_intf import OppRs232Intf @@ -20,6 +25,8 @@ from mpf.core.platform import MatrixLightsPlatform, LedPlatform, SwitchPlatform, DriverPlatform # Minimum firmware versions needed for this module +from mpf.platforms.opp.opp_switch import OPPSwitch + MIN_FW = 0x00000100 BAD_FW_VERSION = 0x01020304 @@ -34,31 +41,37 @@ class HardwarePlatform(MatrixLightsPlatform, LedPlatform, SwitchPlatform, Driver """ - def __init__(self, machine): + def __init__(self, machine) -> None: """Initialise OPP platform.""" super(HardwarePlatform, self).__init__(machine) self.log = logging.getLogger('OPP') self.log.info("Configuring OPP hardware.") - self.opp_connection = {} # type: Dict[str, OPPSerialCommunicator] - self.serial_connections = set() - self.opp_incands = [] - self.incandDict = dict() - self.opp_solenoid = [] - self.solDict = dict() - self.opp_inputs = [] - self.inpDict = dict() - self.inpAddrDict = dict() - self.read_input_msg = {} - self.opp_neopixels = [] - self.neoCardDict = dict() - self.neoDict = dict() + self.opp_connection = {} # type: Dict[str, OPPSerialCommunicator] + self.serial_connections = set() # type: Set[OPPSerialCommunicator] + self.opp_incands = [] # type: List[OPPIncandCard] + # TODO: refactor this into the OPPIncandCard + self.incandDict = dict() # type: Dict[str, OPPIncand] + self.opp_solenoid = [] # type: List[OPPSolenoidCard] + # TODO: refactor this into the OPPSolenoidCard + self.solDict = dict() # type: Dict[str, OPPSolenoid] + self.opp_inputs = [] # type: List[OPPInputCard] + # TODO: refactor this into the OPPInputCard + self.inpDict = dict() # type: Dict[str, OPPSwitch] + # TODO: remove this or opp_inputs + self.inpAddrDict = dict() # type: Dict[str, OPPInputCard] + self.read_input_msg = {} # type: Dict[str, bytearray] + self.opp_neopixels = [] # type: List[OPPNeopixelCard] + # TODO: remove this or opp_neopixels + self.neoCardDict = dict() # type: Dict[str, OPPNeopixelCard] + # TODO: refactor this into the OPPNeopixelCard + self.neoDict = dict() # type: Dict[str, OPPNeopixel] self.numGen2Brd = 0 - self.gen2AddrArr = {} + self.gen2AddrArr = {} # type: Dict[str, List[int]] self.badCRC = 0 self.minVersion = 0xffffffff - self._poll_task = None - self._light_update_task = None + self._poll_task = None # type: asyncio.Task + self._light_update_task = None # type: asyncio.Task self.features['tickless'] = True @@ -816,10 +829,10 @@ class OPPSerialCommunicator(BaseSerialCommunicator): """Manages a Serial connection to the first processor in a OPP serial chain.""" # pylint: disable=too-many-arguments - def __init__(self, platform: HardwarePlatform, port, baud): + def __init__(self, platform: HardwarePlatform, port, baud) -> None: """Initialise Serial Connection to OPP Hardware.""" self.partMsg = b"" - self.chain_serial = None + self.chain_serial = None # type: str self._lost_synch = False super().__init__(platform, port, baud) diff --git a/mpf/tests/test_ConfigPlayers.py b/mpf/tests/test_ConfigPlayers.py index fcd42eb24..28cd8a11a 100644 --- a/mpf/tests/test_ConfigPlayers.py +++ b/mpf/tests/test_ConfigPlayers.py @@ -7,8 +7,7 @@ from mpf.tests.MpfTestCase import MpfTestCase from mpf.core.config_player import ConfigPlayer -PlayCall = namedtuple('PlayCall', 'settings key priority kwargs', - verbose=False) +PlayCall = namedtuple('PlayCall', ['settings', 'key', 'priority', 'kwargs']) class BananaPlayer(DeviceConfigPlayer): diff --git a/mpf/tests/test_CreditsMode.py b/mpf/tests/test_CreditsMode.py index b2a0fb89b..8a0fa03f8 100644 --- a/mpf/tests/test_CreditsMode.py +++ b/mpf/tests/test_CreditsMode.py @@ -14,11 +14,6 @@ def getConfigFile(self): def getMachinePath(self): return 'tests/machine_files/credits/' - def setUp(self): - super().setUp() - # unschedule crash queue because it makes test slow - self.machine.clock.unschedule(self.machine._crash_queue_checker) - def start_game(self, should_work): # shots only work in games so we have to do this a lot self.machine.playfield.add_ball = MagicMock()