refactor: replace try-except blocks with contextlib.suppress for cleaner error handling across multiple files

This commit is contained in:
Jack Lu
2026-05-01 19:30:11 +08:00
committed by Xubin Ren
parent 1c24f10236
commit d9800ecdd2
27 changed files with 98 additions and 195 deletions
+2 -3
View File
@@ -5,6 +5,7 @@ from __future__ import annotations
import ipaddress
import re
import socket
from contextlib import suppress
from urllib.parse import urlparse
_BLOCKED_NETWORKS = [
@@ -30,10 +31,8 @@ def configure_ssrf_whitelist(cidrs: list[str]) -> None:
global _allowed_networks
nets = []
for cidr in cidrs:
try:
with suppress(ValueError):
nets.append(ipaddress.ip_network(cidr, strict=False))
except ValueError:
pass
_allowed_networks = nets