完成 Ruff 全量清理
This commit is contained in:
@@ -137,7 +137,7 @@ class BaseWhitelistAdapter(ABC):
|
||||
|
||||
return False, f"白名单添加失败,API响应: {resp}"
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
msg = f"白名单同步失败: {e}"
|
||||
logger.error(msg)
|
||||
return False, msg
|
||||
@@ -165,7 +165,8 @@ def _get_local_exit_ip() -> str | None:
|
||||
match = re.search(r"(\d{1,3}(?:\.\d{1,3}){3})", text)
|
||||
if match:
|
||||
return match.group(1)
|
||||
except Exception:
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug(f"本机出口 IP 查询失败: {url}: {exc}")
|
||||
continue
|
||||
return None
|
||||
|
||||
@@ -197,6 +198,7 @@ def get_exit_ip_via_proxy(proxy: str) -> str | None:
|
||||
match = re.search(r"(\d{1,3}(?:\.\d{1,3}){3})", text)
|
||||
if match:
|
||||
return match.group(1)
|
||||
except Exception:
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug(f"代理出口 IP 查询失败: {url}: {exc}")
|
||||
continue
|
||||
return None
|
||||
|
||||
@@ -75,7 +75,7 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
if r.get("IP") or r.get("ip")
|
||||
]
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.error(f"获取白名单失败: {e}")
|
||||
return []
|
||||
|
||||
@@ -120,7 +120,7 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
logger.warning(f"白名单添加结果: {text}")
|
||||
return False, text
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.error(f"添加白名单失败: {e}")
|
||||
return False, str(e)
|
||||
|
||||
@@ -141,7 +141,7 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
logger.warning(f"白名单删除结果: {text}")
|
||||
return False, text
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.error(f"删除白名单失败: {e}")
|
||||
return False, str(e)
|
||||
|
||||
@@ -160,7 +160,7 @@ class XiequAdapter(BaseWhitelistAdapter):
|
||||
logger.info(msg)
|
||||
return True, msg
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
msg = f"连接失败: {e}"
|
||||
logger.error(msg)
|
||||
return False, msg
|
||||
|
||||
@@ -115,7 +115,7 @@ class XkdailiAdapter(BaseWhitelistAdapter):
|
||||
logger.warning(f"星空白名单添加失败: {msg}")
|
||||
return ok, msg
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.error(f"星空添加白名单失败: {e}")
|
||||
return False, str(e)
|
||||
|
||||
@@ -136,7 +136,7 @@ class XkdailiAdapter(BaseWhitelistAdapter):
|
||||
logger.warning(f"星空白名单删除失败: {msg}")
|
||||
return ok, msg
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.error(f"星空删除白名单失败: {e}")
|
||||
return False, str(e)
|
||||
|
||||
@@ -159,5 +159,5 @@ class XkdailiAdapter(BaseWhitelistAdapter):
|
||||
# 其他错误(如无效IP),说明认证通过了
|
||||
return True, f"连接成功,API可访问: {msg}"
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
return False, f"连接失败: {e}"
|
||||
|
||||
Reference in New Issue
Block a user