mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
validate super call
This commit is contained in:
parent
98ce83b638
commit
2f7aef8d1c
1 changed files with 12 additions and 4 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue