fix: clean typing issues and refresh runtime dependencies

Align endpoint/module type hints and config reload handling while updating base Python image and package pins to improve build/runtime compatibility.

Made-with: Cursor
This commit is contained in:
DDSRem
2026-03-24 19:21:04 +08:00
parent aae50004b1
commit 517300afe9
14 changed files with 34 additions and 33 deletions

View File

@@ -17,34 +17,44 @@ class ConfigReloadMixin:
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
config_watch = getattr(cls, 'CONFIG_WATCH', None)
config_watch = getattr(cls, "CONFIG_WATCH", None)
if not config_watch:
return
# 检查 on_config_changed 方法是否为异步
is_async = inspect.iscoroutinefunction(cls.on_config_changed)
method_name = 'handle_config_changed'
method_name = "handle_config_changed"
# 创建事件处理函数
def create_handler(is_async):
if is_async:
async def wrapper(self: ConfigReloadMixin, event: Event):
if not event:
return
changed_keys = getattr(event.event_data, "key", set()) & config_watch
changed_keys = (
getattr(event.event_data, "key", set()) & config_watch
)
if not changed_keys:
return
logger.info(f"配置 {', '.join(changed_keys)} 变更,重载 {self.get_reload_name()}...")
await self.on_config_changed()
logger.info(
f"配置 {', '.join(changed_keys)} 变更,重载 {self.get_reload_name()}..."
)
self.on_config_changed()
else:
def wrapper(self: ConfigReloadMixin, event: Event):
if not event:
return
changed_keys = getattr(event.event_data, "key", set()) & config_watch
changed_keys = (
getattr(event.event_data, "key", set()) & config_watch
)
if not changed_keys:
return
logger.info(f"配置 {', '.join(changed_keys)} 变更,重载 {self.get_reload_name()}...")
logger.info(
f"配置 {', '.join(changed_keys)} 变更,重载 {self.get_reload_name()}..."
)
self.on_config_changed()
return wrapper
@@ -52,7 +62,7 @@ class ConfigReloadMixin:
# 创建并设置处理函数
handler = create_handler(is_async)
handler.__module__ = cls.__module__
handler.__qualname__ = f'{cls.__name__}.{method_name}'
handler.__qualname__ = f"{cls.__name__}.{method_name}"
setattr(cls, method_name, handler)
# 添加为事件处理器
eventmanager.add_event_listener(EventType.ConfigChanged, handler)

View File

@@ -1,9 +1,11 @@
from typing import Tuple
import pyotp
class OtpUtils:
@staticmethod
def generate_secret_key(username: str) -> (str, str):
def generate_secret_key(username: str) -> Tuple[str, str]:
try:
secret = pyotp.random_base32()
uri = pyotp.totp.TOTP(secret).provisioning_uri(name='MoviePilot',