python-kasa/kasa/iot
Steven B c5d65b624b
Make get_module return typed module (#892)
Passing in a string still works and returns either `IotModule` or
`SmartModule` type when called on `IotDevice` or `SmartDevice`
respectively. When calling on `Device` will return `Module` type.

Passing in a module type is then typed to that module, i.e.:
```py
smartdev.get_module(FanModule)  # type is FanModule
smartdev.get_module("FanModule")  # type is SmartModule
```
Only thing this doesn't do is check that you can't pass an `IotModule`
to a `SmartDevice.get_module()`. However there is a runtime check which
will return null if the passed `ModuleType` is not a subclass of
`SmartModule`.

Many thanks to @cdce8p for helping with this.
2024-05-03 17:01:21 +02:00
..
modules Use pydantic.v1 namespace on all pydantic versions (#883) 2024-05-01 15:59:35 +02:00
__init__.py Update poetry locks and pre-commit hooks (#837) 2024-04-16 20:21:20 +02:00
iotbulb.py Improve feature setter robustness (#870) 2024-05-02 15:32:06 +02:00
iotdevice.py Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
iotdimmer.py Embed FeatureType inside Feature (#860) 2024-04-24 18:38:52 +02:00
iotlightstrip.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
iotmodule.py Update poetry locks and pre-commit hooks (#837) 2024-04-16 20:21:20 +02:00
iotplug.py Embed FeatureType inside Feature (#860) 2024-04-24 18:38:52 +02:00
iotstrip.py Put modules back on children for wall switches (#881) 2024-04-29 18:34:20 +02:00