Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: replace bare dict with dict[str, Any] in helper cache modules (#35067)

wdeveloper162042ee453b50
diff --git a/api/core/helper/model_provider_cache.py b/api/core/helper/model_provider_cache.py
index 00fcfe0b80b..10d79a82392 100644
--- a/api/core/helper/model_provider_cache.py
+++ b/api/core/helper/model_provider_cache.py
@@ -1,6 +1,7 @@
import json
from enum import StrEnum
from json import JSONDecodeError
+from typing import Any
from extensions.ext_redis import redis_client
@@ -15,7 +16,7 @@ class ProviderCredentialsCache:
def __init__(self, tenant_id: str, identity_id: str, cache_type: ProviderCredentialsCacheType):
self.cache_key = f"{cache_type}_credentials:tenant_id:{tenant_id}:id:{identity_id}"
- def get(self) -> dict | None:
+ def get(self) -> dict[str, Any] | None:
"""
Get cached model provider credentials.
@@ -33,7 +34,7 @@ class ProviderCredentialsCache:
else:
return None
- def set(self, credentials: dict):
+ def set(self, credentials: dict[str, Any]):
"""
Cache model provider credentials.
diff --git a/api/core/helper/provider_cache.py b/api/core/helper/provider_cache.py
index ffb51483868..9f167ca49c1 100644
--- a/api/core/helper/provider_cache.py
+++ b/api/core/helper/provider_cache.py
@@ -17,7 +17,7 @@ class ProviderCredentialsCache(ABC):
"""Generate cache key based on subclass implementation"""
pass
- def get(self) -> dict | None:
+ def get(self) -> dict[str, Any] | None:
"""Get cached provider credentials"""
cached_credentials = redis_client.get(self.cache_key)
if cached_credentials:
@@ -71,7 +71,7 @@ class ToolProviderCredentialsCache(ProviderCredentialsCache):
class NoOpProviderCredentialCache:
"""No-op provider credential cache"""
- def get(self) -> dict | None:
+ def get(self) -> dict[str, Any] | None:
"""Get cached provider credentials"""
return None
diff --git a/api/core/helper/tool_parameter_cache.py b/api/core/helper/tool_parameter_cache.py
index 54674d4ff6b..bf5bf9af03b 100644
--- a/api/core/helper/tool_parameter_cache.py
+++ b/api/core/helper/tool_parameter_cache.py
@@ -1,6 +1,7 @@
import json
from enum import StrEnum
from json import JSONDecodeError
+from typing import Any
from extensions.ext_redis import redis_client
@@ -18,7 +19,7 @@ class ToolParameterCache:
f":identity_id:{identity_id}"
)
- def get(self) -> dict | None:
+ def get(self) -> dict[str, Any] | None:
"""
Get cached model provider credentials.
@@ -36,7 +37,7 @@ class ToolParameterCache:
else:
return None
- def set(self, parameters: dict):
+ def set(self, parameters: dict[str, Any]):
"""Cache model provider credentials."""
redis_client.setex(self.cache_key, 86400, json.dumps(parameters))