aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/hydrorollcore/core.py
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2023-12-05 15:05:17 +0800
committer苏向夜 <fu050409@163.com>2023-12-05 15:05:17 +0800
commita5f3f08f9ae4465b723ed827c72dada74fdb473c (patch)
tree63a2ef6c3b633c7027c492b2c514fcea52a0c7e2 /src/hydrorollcore/core.py
parentc10c8237470b5edb6a383e557324fab06fc8d855 (diff)
downloadinfini-a5f3f08f9ae4465b723ed827c72dada74fdb473c.tar.gz
infini-a5f3f08f9ae4465b723ed827c72dada74fdb473c.zip
:rocket: 优化抽象基类 修复部分声明异常
Diffstat (limited to 'src/hydrorollcore/core.py')
-rw-r--r--src/hydrorollcore/core.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/hydrorollcore/core.py b/src/hydrorollcore/core.py
index 56ec9404..6f6bbcc1 100644
--- a/src/hydrorollcore/core.py
+++ b/src/hydrorollcore/core.py
@@ -2,24 +2,27 @@ import importlib
from typing import List
from .exceptions import RuleLoadError
from .rule import Rule
+from .config import Config
class Core:
- def __init__(self, config):
+ def __init__(self, config: Config):
self.rule_dir = config.rule_dir
self.rules = config.rules
- async def load_rules(self) -> List[Rule]:
+ def load_rules(self) -> List[Rule]:
loaded_rules = []
for rule in self.rules:
try:
module = importlib.import_module(rule)
except ImportError as e:
- raise RuleLoadError(f'Failed to load rule {rule}: {e}') from e
+ raise RuleLoadError(f"Failed to load rule {rule}: {e}") from e
try:
- rule_cls = getattr(module, rule.split('.')[-1])
+ rule_cls = getattr(module, rule.split(".")[-1])
if not issubclass(rule_cls, Rule):
- raise RuleLoadError(f"Class '{rule_cls.__name__}' is not a subclass of 'Rule'")
+ raise RuleLoadError(
+ f"Class '{rule_cls.__name__}' is not a subclass of 'Rule'"
+ )
except AttributeError as e:
raise RuleLoadError(
f"Failed to get rule class from module '{rule}': {e}"