python-kasa/kasa
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
..
iot Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
smart Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
tests Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
__init__.py Move SmartBulb into SmartDevice (#874) 2024-04-29 18:19:44 +01:00
aestransport.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
bulb.py Update interfaces so they all inherit from Device (#893) 2024-05-02 13:55:08 +01:00
cli.py Add LightEffectModule for dynamic light effects on SMART bulbs (#887) 2024-05-02 16:31:12 +02:00
credentials.py Cleanup credentials handling (#605) 2024-01-03 19:26:52 +01:00
device_factory.py Move SmartBulb into SmartDevice (#874) 2024-04-29 18:19:44 +01:00
device_type.py Add temperature control module for smart (#848) 2024-04-22 12:39:07 +01:00
device.py Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
deviceconfig.py Add support for KH100 hub (#847) 2024-04-22 16:24:15 +02:00
discover.py Use pydantic.v1 namespace on all pydantic versions (#883) 2024-05-01 15:59:35 +02:00
effects.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
emeterstatus.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
exceptions.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
fan.py Update interfaces so they all inherit from Device (#893) 2024-05-02 13:55:08 +01:00
feature.py Add LightEffectModule for dynamic light effects on SMART bulbs (#887) 2024-05-02 16:31:12 +02:00
httpclient.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
iotprotocol.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
json.py Generate AES KeyPair lazily (#687) 2024-01-23 15:29:27 +00:00
klaptransport.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
module.py Make get_module return typed module (#892) 2024-05-03 17:01:21 +02:00
plug.py Update poetry locks and pre-commit hooks (#837) 2024-04-16 20:21:20 +02:00
protocol.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00
py.typed Add py.typed to flag that the package is typed (#251) 2021-11-15 18:21:24 +01:00
smartprotocol.py Fix smartprotocol response list handler to handle null reponses (#884) 2024-04-29 14:24:30 +01:00
xortransport.py Enable and convert to future annotations (#838) 2024-04-17 15:39:24 +02:00