修了一点pyright错误喵~
This commit is contained in:
@@ -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。
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user