@@ -1519,9 +1519,8 @@ def ComputeRoundTripTimeout(self, nodeId: int, upperLayerProcessingTimeoutMs: in
15191519 int: The computed timeout value in milliseconds, representing the round-trip time.
15201520 '''
15211521 device = self .GetConnectedDeviceSync (nodeId )
1522- res = self ._ChipStack .Call (lambda : self ._dmLib .pychip_DeviceProxy_ComputeRoundTripTimeout (
1522+ return self ._ChipStack .Call (lambda : self ._dmLib .pychip_DeviceProxy_ComputeRoundTripTimeout (
15231523 device .deviceProxy , upperLayerProcessingTimeoutMs ))
1524- return res
15251524
15261525 def GetRemoteSessionParameters (self , nodeId : int ) -> typing .Optional [SessionParameters ]:
15271526 '''
@@ -1774,7 +1773,7 @@ def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand,
17741773 groupid , self .devCtrl , payload , busyWaitMs = busyWaitMs ).raise_on_error ()
17751774
17761775 # None is the expected return for sending group commands.
1777- return None
1776+ return
17781777
17791778 async def WriteAttribute (self , nodeId : int ,
17801779 attributes : typing .List [typing .Union [
@@ -1968,29 +1967,26 @@ def _parseAttributePathTuple(self, pathTuple: typing.Union[
19681967 if pathTuple == ('*' ) or pathTuple == ():
19691968 # Wildcard
19701969 return ClusterAttribute .AttributePath ()
1971- elif not isinstance (pathTuple , tuple ):
1970+ if not isinstance (pathTuple , tuple ):
19721971 if isinstance (pathTuple , int ):
19731972 return ClusterAttribute .AttributePath (EndpointId = pathTuple )
1974- elif issubclass (pathTuple , ClusterObjects .Cluster ): # type: ignore[misc, arg-type]
1973+ if issubclass (pathTuple , ClusterObjects .Cluster ): # type: ignore[misc, arg-type]
19751974 return ClusterAttribute .AttributePath .from_cluster (EndpointId = None , Cluster = pathTuple ) # type: ignore[arg-type]
1976- elif issubclass (pathTuple , ClusterObjects .ClusterAttributeDescriptor ): # type: ignore[arg-type]
1975+ if issubclass (pathTuple , ClusterObjects .ClusterAttributeDescriptor ): # type: ignore[arg-type]
19771976 return ClusterAttribute .AttributePath .from_attribute (EndpointId = None , Attribute = pathTuple ) # type: ignore[arg-type]
1978- else :
1979- raise ValueError ("Unsupported Attribute Path" )
1980- else :
1981- # endpoint + (cluster) attribute / endpoint + cluster
1982- if issubclass (pathTuple [1 ], ClusterObjects .Cluster ): # type: ignore[misc]
1983- return ClusterAttribute .AttributePath .from_cluster (
1984- EndpointId = pathTuple [0 ], # type: ignore[arg-type]
1985- Cluster = pathTuple [1 ] # type: ignore[arg-type, misc]
1986- )
1987- elif issubclass (pathTuple [1 ], ClusterAttribute .ClusterAttributeDescriptor ): # type: ignore[arg-type, misc]
1988- return ClusterAttribute .AttributePath .from_attribute (
1989- EndpointId = pathTuple [0 ], # type: ignore[arg-type]
1990- Attribute = pathTuple [1 ] # type: ignore[arg-type, misc]
1991- )
1992- else :
1993- raise ValueError ("Unsupported Attribute Path" )
1977+ raise ValueError ("Unsupported Attribute Path" )
1978+ # endpoint + (cluster) attribute / endpoint + cluster
1979+ if issubclass (pathTuple [1 ], ClusterObjects .Cluster ): # type: ignore[misc]
1980+ return ClusterAttribute .AttributePath .from_cluster (
1981+ EndpointId = pathTuple [0 ], # type: ignore[arg-type]
1982+ Cluster = pathTuple [1 ] # type: ignore[arg-type, misc]
1983+ )
1984+ if issubclass (pathTuple [1 ], ClusterAttribute .ClusterAttributeDescriptor ): # type: ignore[arg-type, misc]
1985+ return ClusterAttribute .AttributePath .from_attribute (
1986+ EndpointId = pathTuple [0 ], # type: ignore[arg-type]
1987+ Attribute = pathTuple [1 ] # type: ignore[arg-type, misc]
1988+ )
1989+ raise ValueError ("Unsupported Attribute Path" )
19941990
19951991 def _parseDataVersionFilterTuple (self , pathTuple : typing .List [typing .Tuple [int , typing .Type [ClusterObjects .Cluster ], int ]]):
19961992 endpoint = None
@@ -2027,40 +2023,36 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[
20272023 if pathTuple in [('*' ), ()]:
20282024 # Wildcard
20292025 return ClusterAttribute .EventPath ()
2030- elif not isinstance (pathTuple , tuple ):
2026+ if not isinstance (pathTuple , tuple ):
20312027 # mypy refactor (PR https://github.com/project-chip/connectedhomeip/pull/39827):
20322028 # instantiate class types before passing to from_cluster/from_event
20332029 # because these expect instances, not classes.
20342030 if isinstance (pathTuple , int ):
20352031 return ClusterAttribute .EventPath (EndpointId = pathTuple )
2036- elif isinstance (pathTuple , type ) and issubclass (pathTuple , ClusterObjects .Cluster ):
2032+ if isinstance (pathTuple , type ) and issubclass (pathTuple , ClusterObjects .Cluster ):
20372033 return ClusterAttribute .EventPath .from_cluster (EndpointId = None , Cluster = pathTuple )
2038- elif isinstance (pathTuple , type ) and issubclass (pathTuple , ClusterObjects .ClusterEvent ):
2034+ if isinstance (pathTuple , type ) and issubclass (pathTuple , ClusterObjects .ClusterEvent ):
20392035 return ClusterAttribute .EventPath .from_event (EndpointId = None , Event = pathTuple )
2040- else :
2041- raise ValueError ("Unsupported Event Path" )
2042- else :
2043- if pathTuple [0 ] == '*' :
2044- return ClusterAttribute .EventPath (Urgent = pathTuple [- 1 ])
2045- else :
2046- urgent = bool (pathTuple [- 1 ]) if len (pathTuple ) > 2 else False
2047- # endpoint + (cluster) event / endpoint + cluster
2048- # mypy errors ignored due to valid use of dynamic types (e.g., int, str, or class types).
2049- # Fixing these typing errors is a high risk to affect existing functionality.
2050- # These mismatches are intentional and safe within the current logic.
2051- if issubclass (pathTuple [1 ], ClusterObjects .Cluster ): # type: ignore[arg-type]
2052- return ClusterAttribute .EventPath .from_cluster (
2053- EndpointId = pathTuple [0 ], # type: ignore[arg-type]
2054- Cluster = pathTuple [1 ], Urgent = urgent # type: ignore[arg-type]
2055- )
2056- elif issubclass (pathTuple [1 ], ClusterAttribute .ClusterEvent ): # type: ignore[arg-type]
2057- return ClusterAttribute .EventPath .from_event (
2058- EndpointId = pathTuple [0 ], # type: ignore[arg-type]
2059- Event = pathTuple [1 ], # type: ignore[arg-type]
2060- Urgent = urgent
2061- )
2062- else :
2063- raise ValueError ("Unsupported Attribute Path" )
2036+ raise ValueError ("Unsupported Event Path" )
2037+ if pathTuple [0 ] == '*' :
2038+ return ClusterAttribute .EventPath (Urgent = pathTuple [- 1 ])
2039+ urgent = bool (pathTuple [- 1 ]) if len (pathTuple ) > 2 else False
2040+ # endpoint + (cluster) event / endpoint + cluster
2041+ # mypy errors ignored due to valid use of dynamic types (e.g., int, str, or class types).
2042+ # Fixing these typing errors is a high risk to affect existing functionality.
2043+ # These mismatches are intentional and safe within the current logic.
2044+ if issubclass (pathTuple [1 ], ClusterObjects .Cluster ): # type: ignore[arg-type]
2045+ return ClusterAttribute .EventPath .from_cluster (
2046+ EndpointId = pathTuple [0 ], # type: ignore[arg-type]
2047+ Cluster = pathTuple [1 ], Urgent = urgent # type: ignore[arg-type]
2048+ )
2049+ if issubclass (pathTuple [1 ], ClusterAttribute .ClusterEvent ): # type: ignore[arg-type]
2050+ return ClusterAttribute .EventPath .from_event (
2051+ EndpointId = pathTuple [0 ], # type: ignore[arg-type]
2052+ Event = pathTuple [1 ], # type: ignore[arg-type]
2053+ Urgent = urgent
2054+ )
2055+ raise ValueError ("Unsupported Attribute Path" )
20642056
20652057 async def Read (
20662058 self ,
@@ -2275,8 +2267,7 @@ async def ReadAttribute(
22752267 payloadCapability = payloadCapability )
22762268 if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
22772269 return res
2278- else :
2279- return res .attributes
2270+ return res .attributes
22802271
22812272 async def ReadEvent (
22822273 self ,
@@ -2349,8 +2340,7 @@ async def ReadEvent(
23492340 autoResubscribe = autoResubscribe , payloadCapability = payloadCapability )
23502341 if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
23512342 return res
2352- else :
2353- return res .events
2343+ return res .events
23542344
23552345 def SetIpk (self , ipk : bytes ):
23562346 '''
0 commit comments