Skip to content

Commit

Permalink
Remove try: except: and let badly subclassed items fail
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Oct 18, 2024
1 parent 3e564bf commit c6eda61
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions src/controller/python/chip/clusters/ClusterObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,7 @@ def __init_subclass__(cls, *args, **kwargs) -> None:
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
# register this cluster in the ALL_CLUSTERS dict for quick lookups
try:
ALL_CLUSTERS[cls.id] = cls
except NotImplementedError:
# handle case where the Cluster class is not (fully) subclassed
# and accessing the id property throws a NotImplementedError.
pass
ALL_CLUSTERS[cls.id] = cls

@property
def data_version(self) -> int:
Expand Down Expand Up @@ -301,16 +296,11 @@ class ClusterAttributeDescriptor:
def __init_subclass__(cls, *args, **kwargs) -> None:
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
try:
if cls.standard_attribute:
if cls.cluster_id not in ALL_ATTRIBUTES:
ALL_ATTRIBUTES[cls.cluster_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_ATTRIBUTES[cls.cluster_id][cls.attribute_id] = cls
except NotImplementedError:
# handle case where the ClusterAttribute class is not (fully) subclassed
# and accessing the id property throws a NotImplementedError.
pass
if cls.standard_attribute:
if cls.cluster_id not in ALL_ATTRIBUTES:
ALL_ATTRIBUTES[cls.cluster_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_ATTRIBUTES[cls.cluster_id][cls.attribute_id] = cls

@classmethod
def ToTLV(cls, tag: Union[int, None], value):
Expand Down Expand Up @@ -373,15 +363,11 @@ class ClusterEvent(ClusterObject):
def __init_subclass__(cls, *args, **kwargs) -> None:
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
try:
if cls.cluster_id not in ALL_EVENTS:
ALL_EVENTS[cls.cluster_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls
except NotImplementedError:
# handle case where the ClusterAttribute class is not (fully) subclassed
# and accessing the id property throws a NotImplementedError.
pass

if cls.cluster_id not in ALL_EVENTS:
ALL_EVENTS[cls.cluster_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls

@ChipUtility.classproperty
def cluster_id(self) -> int:
Expand Down

0 comments on commit c6eda61

Please sign in to comment.