Skip to content

Commit c6eda61

Browse files
committed
Remove try: except: and let badly subclassed items fail
1 parent 3e564bf commit c6eda61

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

src/controller/python/chip/clusters/ClusterObjects.py

+11-25
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,7 @@ def __init_subclass__(cls, *args, **kwargs) -> None:
262262
"""Register a subclass."""
263263
super().__init_subclass__(*args, **kwargs)
264264
# register this cluster in the ALL_CLUSTERS dict for quick lookups
265-
try:
266-
ALL_CLUSTERS[cls.id] = cls
267-
except NotImplementedError:
268-
# handle case where the Cluster class is not (fully) subclassed
269-
# and accessing the id property throws a NotImplementedError.
270-
pass
265+
ALL_CLUSTERS[cls.id] = cls
271266

272267
@property
273268
def data_version(self) -> int:
@@ -301,16 +296,11 @@ class ClusterAttributeDescriptor:
301296
def __init_subclass__(cls, *args, **kwargs) -> None:
302297
"""Register a subclass."""
303298
super().__init_subclass__(*args, **kwargs)
304-
try:
305-
if cls.standard_attribute:
306-
if cls.cluster_id not in ALL_ATTRIBUTES:
307-
ALL_ATTRIBUTES[cls.cluster_id] = {}
308-
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
309-
ALL_ATTRIBUTES[cls.cluster_id][cls.attribute_id] = cls
310-
except NotImplementedError:
311-
# handle case where the ClusterAttribute class is not (fully) subclassed
312-
# and accessing the id property throws a NotImplementedError.
313-
pass
299+
if cls.standard_attribute:
300+
if cls.cluster_id not in ALL_ATTRIBUTES:
301+
ALL_ATTRIBUTES[cls.cluster_id] = {}
302+
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
303+
ALL_ATTRIBUTES[cls.cluster_id][cls.attribute_id] = cls
314304

315305
@classmethod
316306
def ToTLV(cls, tag: Union[int, None], value):
@@ -373,15 +363,11 @@ class ClusterEvent(ClusterObject):
373363
def __init_subclass__(cls, *args, **kwargs) -> None:
374364
"""Register a subclass."""
375365
super().__init_subclass__(*args, **kwargs)
376-
try:
377-
if cls.cluster_id not in ALL_EVENTS:
378-
ALL_EVENTS[cls.cluster_id] = {}
379-
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
380-
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls
381-
except NotImplementedError:
382-
# handle case where the ClusterAttribute class is not (fully) subclassed
383-
# and accessing the id property throws a NotImplementedError.
384-
pass
366+
367+
if cls.cluster_id not in ALL_EVENTS:
368+
ALL_EVENTS[cls.cluster_id] = {}
369+
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
370+
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls
385371

386372
@ChipUtility.classproperty
387373
def cluster_id(self) -> int:

0 commit comments

Comments
 (0)