1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
from abc import ABCMeta, abstractmethod class Rule(metaclass=ABCMeta): @abstractmethod def __init__(self): pass @classmethod def __subclasshook__(cls, other): if cls is Rule: return hasattr(other, 'run') and callable(getattr(other, 'run')) return NotImplemented @abstractmethod async def run(self): pass