Formatting
This commit is contained in:
parent
069ee75bf3
commit
f8cdd0f94d
4 changed files with 23 additions and 9 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
class NoDeviceFoundError(Exception):
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -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
|
||||
|
||||
return filtered_devices
|
||||
|
|
Loading…
Reference in a new issue