Skip to content

Commit

Permalink
Merge pull request #147 from natekspencer/dev
Browse files Browse the repository at this point in the history
Revert "Fix cyclic import linting error"
  • Loading branch information
natekspencer authored Mar 4, 2024
2 parents 07add55 + 3141767 commit 87cdc9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Test the devices."""
from vivintpy.devices import get_device_class
from vivintpy.devices.switch import BinarySwitch
from vivintpy.enums import DeviceType


def test_get_device_class() -> None:
"""Test get device class."""
assert get_device_class(DeviceType.BINARY_SWITCH.value) == BinarySwitch
12 changes: 7 additions & 5 deletions vivintpy/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@

if TYPE_CHECKING:
from .alarm_panel import AlarmPanel

DEVICE = "device"


def get_device_class(device_type: str) -> Type[VivintDevice]:
"""Map a device_type string to the class that implements that device."""
# pylint: disable=import-outside-toplevel,cyclic-import
from .camera import Camera
from .door_lock import DoorLock
from .garage_door import GarageDoor
from .switch import BinarySwitch, MultilevelSwitch
from .thermostat import Thermostat
from .wireless_sensor import WirelessSensor

DEVICE = "device"


def get_device_class(device_type: str) -> Type[VivintDevice]:
"""Map a device_type string to the class that implements that device."""
mapping: dict[DeviceType, Type[VivintDevice]] = {
DeviceType.BINARY_SWITCH: BinarySwitch,
DeviceType.CAMERA: Camera,
Expand Down

0 comments on commit 87cdc9c

Please sign in to comment.