This commit is contained in:
minecraft1024a
2025-11-29 19:24:28 +08:00
3 changed files with 12 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ from src.common.logger import get_logger
egg = get_logger("小彩蛋")
def weighted_choice(data: Sequence[str], weights: list[float] | None = None) -> str:
def weighted_choice(data: Sequence[str], weights: Sequence[float] | None = None) -> str:
"""
从 data 中按权重随机返回一条。
若 weights 为 None则所有元素权重默认为 1。

View File

@@ -7,7 +7,7 @@ import time
import traceback
from collections.abc import Callable, Coroutine
from random import choices
from typing import Any
from typing import Any, cast
from rich.traceback import install
@@ -172,6 +172,9 @@ class MainSystem:
logger.warning(f"{calc_name} 不是 BaseInterestCalculator 的有效子类")
continue
# 显式转换类型以修复 Pyright 错误
component_class = cast(type[BaseInterestCalculator], component_class)
# 创建组件实例
calculator_instance = component_class()