mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 18:38:03 +00:00
Create common interfaces for remaining device types (#895)
Introduce common module interfaces across smart and iot devices and provide better typing implementation for getting modules to support this.
This commit is contained in:
25
kasa/modulemapping.py
Normal file
25
kasa/modulemapping.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""Module for Implementation for ModuleMapping and ModuleName types.
|
||||
|
||||
Custom dict for getting typed modules from the module dict.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Generic, TypeVar
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .module import Module
|
||||
|
||||
_ModuleT = TypeVar("_ModuleT", bound="Module")
|
||||
|
||||
|
||||
class ModuleName(str, Generic[_ModuleT]):
|
||||
"""Generic Module name type.
|
||||
|
||||
At runtime this is a generic subclass of str.
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
ModuleMapping = dict
|
Reference in New Issue
Block a user