class PropertyDocBase(object): _spam = 1 def _get_spam(self): return self._spam spam = DynamicClassAttribute(_get_spam, doc="spam spam spam")
class Node(Entity, metaclass=MetaNode): def __init__(self): self._meta = self._meta() def _labels_getter(self) -> FrozenSet[str]: return self._meta.labels def _labels_setter(self, value: Iterable[str]): exception_message = BadLabels.__doc__ try: iter(value) except TypeError: raise BadLabels(exception_message) if not value\ or not all(isinstance(item, str) for item in value)\ or not all(value): raise BadLabels(exception_message) labels = frozenset(value) if not type(self).labels.issubset(labels): raise BadLabels(exception_message) self._meta.labels = labels labels = DynamicClassAttribute( fget=_labels_getter, fset=_labels_setter, ) @classmethod def inflate(cls, node: graph.Node) -> 'Node': raise NotImplementedError def save(self): raise NotImplementedError
class C(object): def foo(self): pass foo.__isabstractmethod__ = NotBool() foo = DynamicClassAttribute(foo)