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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor: replace deprecated Iterator with Generator in contextmanagers #35433 (#35441)
Mallikharjuna Mulpuri0b60bf6ef081
diff --git a/api/core/app/file_access/scope.py b/api/core/app/file_access/scope.pyindex 80d504ef1c0..a583301f9b7 100644--- a/api/core/app/file_access/scope.py+++ b/api/core/app/file_access/scope.py@@ -1,6 +1,6 @@from __future__ import annotations-from collections.abc import Iterator+from collections.abc import Generator # Changed from Iteratorfrom contextlib import contextmanagerfrom contextvars import ContextVarfrom dataclasses import dataclass@@ -32,7 +32,7 @@ def get_current_file_access_scope() -> FileAccessScope | None:@contextmanager-def bind_file_access_scope(scope: FileAccessScope) -> Iterator[None]:+def bind_file_access_scope(scope: FileAccessScope) -> Generator[None, None, None]: # Changed from Iterator[None]token = _current_file_access_scope.set(scope)try:yielddiff --git a/api/libs/flask_utils.py b/api/libs/flask_utils.pyindex 52fc787c790..838af2bf321 100644--- a/api/libs/flask_utils.py+++ b/api/libs/flask_utils.py@@ -1,5 +1,5 @@import contextvars-from collections.abc import Iterator+from collections.abc import Generator # Changed from Iteratorfrom contextlib import contextmanagerfrom typing import TYPE_CHECKING@@ -13,7 +13,7 @@ if TYPE_CHECKING:def preserve_flask_contexts(flask_app: Flask,context_vars: contextvars.Context,-) -> Iterator[None]:+) -> Generator[None, None, None]: # Changed from Iterator[None]"""A context manager that handles:1. flask-login's UserProxy copydiff --git a/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_sql.py b/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_sql.pyindex b2908ebdae7..11398efb586 100644--- a/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_sql.py+++ b/api/providers/vdb/vdb-analyticdb/src/dify_vdb_analyticdb/analyticdb_vector_sql.py@@ -1,6 +1,6 @@import jsonimport uuid-from collections.abc import Iterator+from collections.abc import Generator # Added Generatorfrom contextlib import contextmanagerfrom typing import Any@@ -75,7 +75,7 @@ class AnalyticdbVectorBySql:)@contextmanager- def _get_cursor(self) -> Iterator[Any]:+ def _get_cursor(self) -> Generator[Any, None, None]: # Changed from Iterator[Any]assert self.pool is not None, "Connection pool is not initialized"conn = self.pool.getconn()cur = conn.cursor()diff --git a/api/services/file_service.py b/api/services/file_service.pyindex 52da2a7951f..f60afe2f19d 100644--- a/api/services/file_service.py+++ b/api/services/file_service.py@@ -2,7 +2,7 @@ import base64import hashlibimport osimport uuid-from collections.abc import Iterator, Sequence+from collections.abc import Generator, Sequence # Changed Iterator to Generatorfrom contextlib import contextmanager, suppressfrom tempfile import NamedTemporaryFilefrom typing import Literal@@ -324,7 +324,7 @@ class FileService:def build_upload_files_zip_tempfile(*,upload_files: Sequence[UploadFile],- ) -> Iterator[str]:+ ) -> Generator[str, None, None]: # Changed from Iterator[str]"""Build a ZIP from `UploadFile`s and yield a tempfile path.