From: Benjamin Braatz Date: Tue, 2 Mar 2021 08:49:24 +0000 (+0100) Subject: Repair type annotations in util.py X-Git-Tag: v0.3.0~89 X-Git-Url: http://git.graph-it.com/?a=commitdiff_plain;h=518eaba4a4bb3d73e82de2ff0b294bf57474f4e6;p=graphit%2Fcontrolpi.git Repair type annotations in util.py --- diff --git a/controlpi/__init__.py b/controlpi/__init__.py index e7d424f..8657d2a 100644 --- a/controlpi/__init__.py +++ b/controlpi/__init__.py @@ -95,7 +95,7 @@ import asyncio import collections.abc from typing import Mapping, Any -from controlpi.messagebus import MessageBus +from controlpi.messagebus import MessageBus, Message from controlpi.pluginregistry import PluginRegistry diff --git a/controlpi/plugins/util.py b/controlpi/plugins/util.py index 7b8ec50..7d3b511 100644 --- a/controlpi/plugins/util.py +++ b/controlpi/plugins/util.py @@ -1,24 +1,24 @@ """Provide utility plugins for all kinds of systems. TODO: documentation, doctests, check configurations +TODO: Keyboard, State, AndState, OrState """ import asyncio -from controlpi import BasePlugin, PluginConfiguration +from controlpi import BasePlugin, Message, PluginConfiguration class Log(BasePlugin): - async def _log(self, message: str) -> None: + async def _log(self, message: Message) -> None: print(f"{self._name}: {message}") def _process_conf(self, conf: PluginConfiguration) -> None: - receives = [{}] self._bus.register(self._name, [], conf['filter'], self._log) super()._process_conf(conf) class Init(BasePlugin): - async def _execute(self, message: str) -> None: + async def _execute(self, message: Message) -> None: for message in self._messages: await self._bus.send(message) @@ -42,7 +42,7 @@ class Init(BasePlugin): class Wait(BasePlugin): - async def _wait(self, message: str) -> None: + async def _wait(self, message: Message) -> None: await asyncio.sleep(self._seconds) await self._bus.send({'sender': self._name, 'event': 'finished'})