Skip to content

Commit 14f58b6

Browse files
committed
just backing up some changes on builtin typehinting
1 parent 55d9b9c commit 14f58b6

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

src/controller/python/chip/ChipDeviceCtrl.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727

2828
# Needed to use types in type hints before they are fully defined.
2929
from __future__ import absolute_import, annotations, print_function
30+
from .native import PyChipError
31+
from .interaction_model import SessionParameters, SessionParametersStruct
32+
from .crypto import p256keypair
33+
from .clusters.CHIPClusters import ChipClusters
34+
from .clusters import Command as ClusterCommand
35+
from .clusters import ClusterObjects as ClusterObjects
36+
from .clusters import Attribute as ClusterAttribute
37+
from . import discovery
38+
from . import clusters as Clusters
39+
from . import FabricAdmin
40+
import dacite # type: ignore
3041

3142
import asyncio
3243
import builtins
@@ -43,18 +54,9 @@
4354
c_uint16, c_uint32, c_uint64, c_void_p, cast, create_string_buffer, pointer, py_object, resize, string_at)
4455
from dataclasses import dataclass
4556

46-
import dacite # type: ignore
57+
from . import ChipStack # Ensure this import is correct
58+
builtins.chipStack = cast(ChipStack, builtins.chipStack)
4759

48-
from . import FabricAdmin
49-
from . import clusters as Clusters
50-
from . import discovery
51-
from .clusters import Attribute as ClusterAttribute
52-
from .clusters import ClusterObjects as ClusterObjects
53-
from .clusters import Command as ClusterCommand
54-
from .clusters.CHIPClusters import ChipClusters
55-
from .crypto import p256keypair
56-
from .interaction_model import SessionParameters, SessionParametersStruct
57-
from .native import PyChipError
5860

5961
__all__ = ["ChipDeviceController", "CommissioningParameters"]
6062

src/controller/python/chip/ChipStack.py

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
from .interaction_model import delegate as im
4242
from .storage import PersistentStorage
4343

44+
from typing import TYPE_CHECKING, cast
45+
46+
4447
__all__ = [
4548
"DeviceStatusStruct",
4649
"ChipStackException",
@@ -283,3 +286,11 @@ def _loadLib(self):
283286
self._ChipStackLib.pychip_DeviceController_PostTaskOnChipThread.argtypes = [
284287
_ChipThreadTaskRunnerFunct, py_object]
285288
self._ChipStackLib.pychip_DeviceController_PostTaskOnChipThread.restype = PyChipError
289+
290+
291+
if TYPE_CHECKING:
292+
from .ChipStack import ChipStack
293+
builtins.chipStack: ChipStack
294+
295+
# if TYPE_CHECKING:
296+
# builtins.chipStack: ChipStack
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import Any, Callable
2+
3+
4+
class ChipStack:
5+
_ChipStackLib: Any
6+
_chipDLLPath: Any
7+
devMgr: Any
8+
_enableServerInteractions: bool
9+
cbHandleChipThreadRun: Any
10+
_persistentStorage: Any
11+
12+
def __init__(self, persistentStoragePath: str, enableServerInteractions: bool = True) -> None: ...
13+
def GetStorageManager(self) -> Any: ...
14+
@property
15+
def enableServerInteractions(self) -> bool: ...
16+
def Shutdown(self) -> None: ...
17+
def Call(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> Any: ...
18+
async def CallAsyncWithResult(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> Any: ...
19+
async def CallAsync(self, callFunct: Callable[..., Any], timeoutMs: int = None) -> None: ...
20+
def PostTaskOnChipThread(self, callFunct: Callable[..., Any]) -> Any: ...
21+
def LocateChipDLL(self) -> str: ...

0 commit comments

Comments
 (0)