执行 Ruff 安全自动修复
This commit is contained in:
@@ -13,7 +13,7 @@ from .xiequ import XiequAdapter
|
||||
from .xkdaili import XkdailiAdapter
|
||||
|
||||
# ── 平台注册表 ──
|
||||
_PLATFORM_REGISTRY: dict[str, Type[BaseWhitelistAdapter]] = {
|
||||
_PLATFORM_REGISTRY: dict[str, type[BaseWhitelistAdapter]] = {
|
||||
"xiequ": XiequAdapter,
|
||||
"xkdaili": XkdailiAdapter,
|
||||
}
|
||||
@@ -49,7 +49,7 @@ _PLATFORM_LABELS: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
def create_adapter(platform: str, credentials: dict) -> Optional[BaseWhitelistAdapter]:
|
||||
def create_adapter(platform: str, credentials: dict) -> BaseWhitelistAdapter | None:
|
||||
"""根据平台标识符和凭据创建适配器实例。"""
|
||||
cls = _PLATFORM_REGISTRY.get(platform)
|
||||
if not cls:
|
||||
|
||||
@@ -8,7 +8,6 @@ import re
|
||||
import threading
|
||||
import time
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from loguru import logger
|
||||
@@ -144,12 +143,12 @@ class BaseWhitelistAdapter(ABC):
|
||||
return False, msg
|
||||
|
||||
@staticmethod
|
||||
def get_local_exit_ip() -> Optional[str]:
|
||||
def get_local_exit_ip() -> str | None:
|
||||
"""获取本机当前公网出口IP(不走代理)。"""
|
||||
return _get_local_exit_ip()
|
||||
|
||||
|
||||
def _get_local_exit_ip() -> Optional[str]:
|
||||
def _get_local_exit_ip() -> str | None:
|
||||
"""获取本机当前公网出口IP(不走代理)。"""
|
||||
targets = [
|
||||
"https://myip.ipip.net",
|
||||
@@ -171,7 +170,7 @@ def _get_local_exit_ip() -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def get_exit_ip_via_proxy(proxy: str) -> Optional[str]:
|
||||
def get_exit_ip_via_proxy(proxy: str) -> str | None:
|
||||
"""通过代理获取出口IP。"""
|
||||
targets = [
|
||||
"https://qifu-api.baidubce.com/ip/local/geo/v1/district",
|
||||
|
||||
Reference in New Issue
Block a user