From a5f3f08f9ae4465b723ed827c72dada74fdb473c Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Tue, 5 Dec 2023 15:05:17 +0800 Subject: :rocket: 优化抽象基类 修复部分声明异常 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hydrorollcore/rule.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/hydrorollcore/rule.py') diff --git a/src/hydrorollcore/rule.py b/src/hydrorollcore/rule.py index eb4b92cd..a7e5d9a7 100644 --- a/src/hydrorollcore/rule.py +++ b/src/hydrorollcore/rule.py @@ -14,16 +14,12 @@ class RuleLoadType(Enum): 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 + raise NotImplementedError @abstractmethod async def run(self): - pass + raise NotImplementedError -- cgit v1.2.3-70-g09d2 From d3076462c53afc848622052611a2ed7c241434e9 Mon Sep 17 00:00:00 2001 From: 苏向夜 Date: Tue, 5 Dec 2023 15:20:12 +0800 Subject: :sparkles: 依照文档增加Rule基类参数 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hydrorollcore/rule.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/hydrorollcore/rule.py') diff --git a/src/hydrorollcore/rule.py b/src/hydrorollcore/rule.py index a7e5d9a7..a1b07cb9 100644 --- a/src/hydrorollcore/rule.py +++ b/src/hydrorollcore/rule.py @@ -16,6 +16,9 @@ class RuleLoadType(Enum): class Rule(metaclass=ABCMeta): """规则基类""" + name: str + priority: int = 0 + @abstractmethod def __init__(self): raise NotImplementedError -- cgit v1.2.3-70-g09d2