From f8cdd0f94d251a513fb7815b3c7d1bb8c796e82a Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Fri, 4 Nov 2022 09:03:53 +0100 Subject: [PATCH] Formatting --- src/config/hotreloader.py | 4 ++-- src/models/devices.py | 3 +++ src/models/exceptions.py | 2 +- src/models/helper.py | 23 +++++++++++++++++------ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/config/hotreloader.py b/src/config/hotreloader.py index 3971239..a6377c4 100644 --- a/src/config/hotreloader.py +++ b/src/config/hotreloader.py @@ -21,7 +21,7 @@ class HotReloader(FileSystemEventHandler): def __init__(self, path): if not DEPENDENCY_INSTALLED: return - + self.path = path self.observer = Observer() self.observer.schedule(self, path, recursive=True) @@ -30,7 +30,7 @@ class HotReloader(FileSystemEventHandler): def __del__(self): if not DEPENDENCY_INSTALLED: return - + self.observer.stop() self.observer.join() diff --git a/src/models/devices.py b/src/models/devices.py index d8333f4..4016d66 100644 --- a/src/models/devices.py +++ b/src/models/devices.py @@ -2,8 +2,10 @@ import abc from models.light import LightColor + class GenericDevice: """A generic device.""" + def __init__(self, name: str): self.name = name @@ -41,4 +43,5 @@ class LightDevice(SwitchDevice): class AllDevice(LightDevice): """Abstract device class that offers all device operations.""" + pass diff --git a/src/models/exceptions.py b/src/models/exceptions.py index 57ff946..afc2cbd 100644 --- a/src/models/exceptions.py +++ b/src/models/exceptions.py @@ -1,2 +1,2 @@ class NoDeviceFoundError(Exception): - pass \ No newline at end of file + pass diff --git a/src/models/helper.py b/src/models/helper.py index 8e4f877..78c41c1 100644 --- a/src/models/helper.py +++ b/src/models/helper.py @@ -4,14 +4,25 @@ from models.exceptions import NoDeviceFoundError from models.groups import DeviceGroup, Room -DEVICE_TYPE = TypeVar("DEVICE_TYPE", type(GenericDevice), type(SwitchDevice), type(LightDevice), type(Room), type(DeviceGroup)) +DEVICE_TYPE = TypeVar( + "DEVICE_TYPE", + type(GenericDevice), + type(SwitchDevice), + type(LightDevice), + type(Room), + type(DeviceGroup), +) -def filter_devices(devices: list[GenericDevice], type: DEVICE_TYPE) -> list[DEVICE_TYPE]: +def filter_devices( + devices: list[GenericDevice], type: DEVICE_TYPE +) -> list[DEVICE_TYPE]: """Filters out devices that are not of a specific type.""" - filtered_devices: list[type] = [device for device in devices if isinstance(device, type)] - + filtered_devices: list[type] = [ + device for device in devices if isinstance(device, type) + ] + if len(filtered_devices) == 0: raise NoDeviceFoundError(f"No devices of type {type} found.") - - return filtered_devices \ No newline at end of file + + return filtered_devices