refactor: replace try-except blocks with contextlib.suppress for cleaner exception handling (#24284)

This commit is contained in:
Guangdong Liu
2025-08-21 18:18:49 +08:00
committed by GitHub
parent ad8e82ee1d
commit 1abf1240b2
16 changed files with 52 additions and 88 deletions

View File

@@ -1,3 +1,4 @@
import contextlib
from copy import deepcopy
from typing import Any, Optional, Protocol
@@ -111,14 +112,12 @@ class ProviderConfigEncrypter:
for field_name, field in fields.items():
if field.type == BasicProviderConfig.Type.SECRET_INPUT:
if field_name in data:
try:
with contextlib.suppress(Exception):
# if the value is None or empty string, skip decrypt
if not data[field_name]:
continue
data[field_name] = encrypter.decrypt_token(self.tenant_id, data[field_name])
except Exception:
pass
self.provider_config_cache.set(data)
return data