mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Add generic typing support to features
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import pytest
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import pytest
|
||||
from typing_extensions import assert_type
|
||||
|
||||
from kasa import Feature
|
||||
from kasa.iot import IotDevice
|
||||
from kasa.smart import SmartDevice
|
||||
from kasa.tests.conftest import dimmable_iot, parametrize
|
||||
@@ -16,7 +20,9 @@ async def test_brightness_component(dev: SmartDevice):
|
||||
assert "brightness" in dev._components
|
||||
|
||||
# Test getting the value
|
||||
feature = dev.features["brightness"]
|
||||
feature = dev.features[Feature.Id.BRIGHTNESS]
|
||||
if TYPE_CHECKING:
|
||||
assert_type(feature.value, int)
|
||||
assert isinstance(feature.value, int)
|
||||
assert feature.value > 1 and feature.value <= 100
|
||||
|
||||
|
@@ -18,7 +18,7 @@ class DummyDevice:
|
||||
def dummy_feature() -> Feature:
|
||||
# create_autospec for device slows tests way too much, so we use a dummy here
|
||||
|
||||
feat = Feature(
|
||||
feat: Feature = Feature(
|
||||
device=DummyDevice(), # type: ignore[arg-type]
|
||||
id="dummy_feature",
|
||||
name="dummy_feature",
|
||||
|
Reference in New Issue
Block a user