From 2f7aef8d1c519c7a777b495998013c0c92a65313 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 16 Jun 2021 19:15:57 +0200 Subject: [PATCH] validate super call --- openpype/pipeline/lib/attribute_definitions.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/openpype/pipeline/lib/attribute_definitions.py b/openpype/pipeline/lib/attribute_definitions.py index 038738a194..55b4445f11 100644 --- a/openpype/pipeline/lib/attribute_definitions.py +++ b/openpype/pipeline/lib/attribute_definitions.py @@ -11,9 +11,10 @@ class AbstractAttrDefMeta(ABCMeta): """ def __call__(self, *args, **kwargs): obj = super(AbstractAttrDefMeta, self).__call__(*args, **kwargs) - if not hasattr(obj, "key"): - raise TypeError("<{}> must have defined 'key' attribute.".format( - obj.__class__.__name__ + init_class = getattr(obj, "__init__class__", None) + if init_class is not AbtractAttrDef: + raise TypeError("{} super was not called in __init__.".format( + type(obj) )) return obj @@ -34,10 +35,17 @@ class AbtractAttrDef: Args: key(str): Under which key will be attribute value stored. + label(str): Attribute label. + tooltip(str): Attribute tooltip. """ - def __init__(self, key): + def __init__(self, key, label=None, tooltip=None): self.key = key + self.label = label + self.tooltip = tooltip + + self.__init__class__ = AbtractAttrDef + @abstractmethod def convert_value(self, value):