Skip to content

Commit

Permalink
just backing up some changes on builtin typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine committed Feb 4, 2025
1 parent 55d9b9c commit 14f58b6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@

# Needed to use types in type hints before they are fully defined.
from __future__ import absolute_import, annotations, print_function
from .native import PyChipError
from .interaction_model import SessionParameters, SessionParametersStruct
from .crypto import p256keypair
from .clusters.CHIPClusters import ChipClusters
from .clusters import Command as ClusterCommand
from .clusters import ClusterObjects as ClusterObjects
from .clusters import Attribute as ClusterAttribute
from . import discovery
from . import clusters as Clusters
from . import FabricAdmin
import dacite # type: ignore

import asyncio
import builtins
Expand All @@ -43,18 +54,9 @@
c_uint16, c_uint32, c_uint64, c_void_p, cast, create_string_buffer, pointer, py_object, resize, string_at)
from dataclasses import dataclass

import dacite # type: ignore
from . import ChipStack # Ensure this import is correct
builtins.chipStack = cast(ChipStack, builtins.chipStack)

from . import FabricAdmin
from . import clusters as Clusters
from . import discovery
from .clusters import Attribute as ClusterAttribute
from .clusters import ClusterObjects as ClusterObjects
from .clusters import Command as ClusterCommand
from .clusters.CHIPClusters import ChipClusters
from .crypto import p256keypair
from .interaction_model import SessionParameters, SessionParametersStruct
from .native import PyChipError

__all__ = ["ChipDeviceController", "CommissioningParameters"]

Expand Down
11 changes: 11 additions & 0 deletions src/controller/python/chip/ChipStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
from .interaction_model import delegate as im
from .storage import PersistentStorage

from typing import TYPE_CHECKING, cast


__all__ = [
"DeviceStatusStruct",
"ChipStackException",
Expand Down Expand Up @@ -283,3 +286,11 @@ def _loadLib(self):
self._ChipStackLib.pychip_DeviceController_PostTaskOnChipThread.argtypes = [
_ChipThreadTaskRunnerFunct, py_object]
self._ChipStackLib.pychip_DeviceController_PostTaskOnChipThread.restype = PyChipError


if TYPE_CHECKING:
from .ChipStack import ChipStack
builtins.chipStack: ChipStack

# if TYPE_CHECKING:
# builtins.chipStack: ChipStack
21 changes: 21 additions & 0 deletions src/controller/python/chip/ChipStack.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Any, Callable


class ChipStack:
_ChipStackLib: Any
_chipDLLPath: Any
devMgr: Any
_enableServerInteractions: bool
cbHandleChipThreadRun: Any
_persistentStorage: Any

def __init__(self, persistentStoragePath: str, enableServerInteractions: bool = True) -> None: ...
def GetStorageManager(self) -> Any: ...
@property
def enableServerInteractions(self) -> bool: ...
def Shutdown(self) -> None: ...
def Call(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> Any: ...
async def CallAsyncWithResult(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> Any: ...
async def CallAsync(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> None: ...
def PostTaskOnChipThread(self, callFunct: Callable[..., Any]) -> Any: ...
def LocateChipDLL(self) -> str: ...

0 comments on commit 14f58b6

Please sign in to comment.