Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/core/abstractattribute.py
Show All 10 Lines | class AbstractAttribute: | ||||
empty method def boilerplate. Like abc.abstractmethod, the class containing | empty method def boilerplate. Like abc.abstractmethod, the class containing | ||||
AbstractAttributes must inherit from :class:`abc.ABC` or use the | AbstractAttributes must inherit from :class:`abc.ABC` or use the | ||||
:class:`abc.ABCMeta` metaclass. | :class:`abc.ABCMeta` metaclass. | ||||
Usage example:: | Usage example:: | ||||
import abc | import abc | ||||
class ClassContainingAnAbstractAttribute(abc.ABC): | class ClassContainingAnAbstractAttribute(abc.ABC): | ||||
foo = AbstractAttribute('descriptive docstring for foo') | foo: Union[AbstractAttribute, Any] = \ | ||||
AbstractAttribute('docstring for foo') | |||||
""" | """ | ||||
__isabstractmethod__ = True | __isabstractmethod__ = True | ||||
def __init__(self, docstring=None): | def __init__(self, docstring=None): | ||||
if docstring is not None: | if docstring is not None: | ||||
self.__doc__ = 'AbstractAttribute: ' + docstring | self.__doc__ = 'AbstractAttribute: ' + docstring |