执行 Ruff 安全自动修复

This commit is contained in:
yml2213
2026-08-31 10:28:14 +08:00
parent 2a1d27f953
commit b58c6b4357
145 changed files with 940 additions and 993 deletions
+10 -9
View File
@@ -2,7 +2,8 @@
import threading
import time
from typing import Callable, Optional, Protocol
from collections.abc import Callable
from typing import Protocol
import requests
from loguru import logger
@@ -19,7 +20,7 @@ class WhitelistSyncer(Protocol):
def sync_ip(self, ip: str) -> tuple[bool, str]: ...
def get_local_exit_ip(self) -> Optional[str]: ...
def get_local_exit_ip(self) -> str | None: ...
class ProxyResolver:
@@ -28,11 +29,11 @@ class ProxyResolver:
def __init__(
self,
api_url: str,
whitelist_syncer: Optional[WhitelistSyncer] = None,
log_func: Optional[LogFunc] = None,
whitelist_syncer: WhitelistSyncer | None = None,
log_func: LogFunc | None = None,
sync_local_exit_ip: bool = False,
sync_whitelist_once: bool = True,
stop_event: Optional[threading.Event] = None,
stop_event: threading.Event | None = None,
):
self.api_url = api_url
self.whitelist_syncer = whitelist_syncer
@@ -40,7 +41,7 @@ class ProxyResolver:
self.sync_local_exit_ip = sync_local_exit_ip
self.sync_whitelist_once = sync_whitelist_once
self.stop_event = stop_event
self._last_synced_ip: Optional[str] = None
self._last_synced_ip: str | None = None
self._has_synced_whitelist = False
def _is_stopped(self) -> bool:
@@ -95,7 +96,7 @@ class ProxyResolver:
self,
max_attempts: int = 4,
return_all: bool = False,
) -> tuple[Optional[str | list[str]], str]:
) -> tuple[str | list[str] | None, str]:
"""
获取并验证代理。
@@ -178,8 +179,8 @@ def resolve_working_proxy(
whitelist_platform: str = "xiequ",
whitelist_credentials: dict | None = None,
max_attempts: int = 4,
log_func: Optional[LogFunc] = None,
) -> tuple[Optional[str], str]:
log_func: LogFunc | None = None,
) -> tuple[str | None, str]:
"""从代理 API 获取可用代理,自动处理白名单同步。"""
syncer = (
DouyuWhitelistSyncer(