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.

chore: bump pyrefly version (#39876)

Asuka Minato982c0667e193
diff --git a/api/controllers/console/app/agent_config_inspector.py b/api/controllers/console/app/agent_config_inspector.py
index 6fd28bcbb29..930dcd7814b 100644
--- a/api/controllers/console/app/agent_config_inspector.py
+++ b/api/controllers/console/app/agent_config_inspector.py
@@ -1324,4 +1324,5 @@ class AgentConfigFileApi(Resource):
)
+# pyrefly: ignore [unresolvable-dunder-all]
__all__ = [name for name, value in globals().items() if inspect.isclass(value) and issubclass(value, Resource)]
diff --git a/api/controllers/openapi/apps.py b/api/controllers/openapi/apps.py
index 9a3e609b70a..f6dace6fd56 100644
--- a/api/controllers/openapi/apps.py
+++ b/api/controllers/openapi/apps.py
@@ -3,7 +3,7 @@
from __future__ import annotations
import uuid as _uuid
-from typing import Any, cast
+from typing import Any
from flask_restx import Resource
from sqlalchemy.orm import Session
@@ -247,8 +247,8 @@ class AppListApi(Resource):
env = AppListResponse(
page=query.page,
limit=query.limit,
- total=cast(int, pagination.total),
- has_more=query.page * query.limit < cast(int, pagination.total),
+ total=pagination.total,
+ has_more=query.page * query.limit < pagination.total,
data=items,
)
return env
diff --git a/api/core/app/apps/common/workflow_response_converter.py b/api/core/app/apps/common/workflow_response_converter.py
index 01ed7c2c842..68eb95fab36 100644
--- a/api/core/app/apps/common/workflow_response_converter.py
+++ b/api/core/app/apps/common/workflow_response_converter.py
@@ -871,6 +871,7 @@ class WorkflowResponseConverter:
files.append(value.value.to_dict())
case ArrayFileSegment():
files.extend([i.to_dict() for i in value.value])
+ # pyrefly: ignore [unreachable-match-case]
case File():
files.append(value.to_dict())
case list():
diff --git a/api/core/app/apps/workflow/active_workflow_tasks.py b/api/core/app/apps/workflow/active_workflow_tasks.py
index 4aa23ad1ccf..ad2d8cfb5e0 100644
--- a/api/core/app/apps/workflow/active_workflow_tasks.py
+++ b/api/core/app/apps/workflow/active_workflow_tasks.py
@@ -1,7 +1,7 @@
"""In-process registry for workflow application task IDs."""
import threading
-from collections.abc import Iterator
+from collections.abc import Generator
from contextlib import contextmanager
_active_task_ids: set[str] = set()
@@ -9,7 +9,7 @@ _active_task_ids_lock = threading.RLock()
@contextmanager
-def active_workflow_task(task_id: str) -> Iterator[None]:
+def active_workflow_task(task_id: str) -> Generator[None]:
"""Register a workflow application task ID for the duration of a workflow run."""
if not task_id:
raise ValueError("task_id must not be empty")
diff --git a/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py b/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py
index 7b38d973943..32ec381d798 100644
--- a/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py
+++ b/api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py
@@ -378,6 +378,7 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline[EasyUIAppGenerat
match content:
case TextPromptMessageContent():
delta_text += content.data
+ # pyrefly: ignore [unreachable-match-case]
case str():
delta_text += content
case _:
diff --git a/api/core/mcp/session/base_session.py b/api/core/mcp/session/base_session.py
index 00f6ac8fa3e..f785ae6509f 100644
--- a/api/core/mcp/session/base_session.py
+++ b/api/core/mcp/session/base_session.py
@@ -229,9 +229,9 @@ class BaseSession[
self._write_stream.put(SessionMessage(message=JSONRPCMessage(jsonrpc_request), metadata=metadata))
timeout = DEFAULT_RESPONSE_READ_TIMEOUT
if request_read_timeout_seconds is not None:
- timeout = float(request_read_timeout_seconds.total_seconds())
+ timeout = request_read_timeout_seconds.total_seconds()
elif self._session_read_timeout_seconds is not None:
- timeout = float(self._session_read_timeout_seconds.total_seconds())
+ timeout = self._session_read_timeout_seconds.total_seconds()
while True:
try:
response_or_error = response_queue.get(timeout=timeout)
@@ -241,6 +241,7 @@ class BaseSession[
continue
match response_or_error:
+ # pyrefly: ignore [unreachable-match-case]
case None:
raise MCPConnectionError(
ErrorData(
diff --git a/api/core/ops/utils.py b/api/core/ops/utils.py
index 50cccd9d088..5e99ed89a9d 100644
--- a/api/core/ops/utils.py
+++ b/api/core/ops/utils.py
@@ -34,6 +34,7 @@ def measure_time():
try:
yield timing_info
finally:
+ # pyrefly: ignore [bad-assignment]
timing_info["end"] = datetime.now()
diff --git a/api/core/plugin/plugin_service.py b/api/core/plugin/plugin_service.py
index 08546c90845..a0147adadfd 100644
--- a/api/core/plugin/plugin_service.py
+++ b/api/core/plugin/plugin_service.py
@@ -16,7 +16,7 @@ metadata.
import logging
import time
-from collections.abc import Iterator, Mapping, Sequence
+from collections.abc import Generator, Mapping, Sequence
from contextlib import contextmanager
from mimetypes import guess_type
from typing import Literal, Protocol
@@ -373,7 +373,7 @@ class PluginService:
@contextmanager
def _plugin_model_providers_refresh_lock(
cls, tenant_id: str, generation: int, *, wait_timeout: float
- ) -> Iterator[bool]:
+ ) -> Generator[bool]:
lock_key = cls._get_plugin_model_providers_lock_key(tenant_id, generation)
try:
refresh_lock: _RedisLock = redis_client.lock(
diff --git a/api/core/tools/utils/web_reader_tool.py b/api/core/tools/utils/web_reader_tool.py
index c156fd888f7..2e630b803eb 100644
--- a/api/core/tools/utils/web_reader_tool.py
+++ b/api/core/tools/utils/web_reader_tool.py
@@ -2,7 +2,7 @@ import mimetypes
import re
from collections.abc import Sequence
from dataclasses import dataclass
-from typing import Any, cast
+from typing import Any
from urllib.parse import unquote
import charset_normalizer
@@ -58,7 +58,7 @@ def get_url(url: str, user_agent: str | None = None) -> str:
return f"Unsupported content-type [{main_content_type}] of URL."
if main_content_type in extract_processor.SUPPORT_URL_CONTENT_TYPES:
- return cast(str, ExtractProcessor.load_from_url(url, return_text=True))
+ return ExtractProcessor.load_from_url(url, return_text=True)
response = remote_fetcher.make_request("GET", url, headers=headers, follow_redirects=True, timeout=(120, 300))
elif response.status_code == 403:
diff --git a/api/dev/lint_response_contracts.py b/api/dev/lint_response_contracts.py
index 6cfc1c6b446..5914f1db469 100644
--- a/api/dev/lint_response_contracts.py
+++ b/api/dev/lint_response_contracts.py
@@ -668,6 +668,7 @@ def checks_for_file(file_path: Path, repo_root: Path) -> list[ContractCheck]:
def as_jsonable(check: ContractCheck) -> dict[str, Any]:
data = asdict(check)
+ # pyrefly: ignore [bad-assignment]
data["documented"] = {str(status): model for status, model in check.documented.items()}
return data
diff --git a/api/libs/helper.py b/api/libs/helper.py
index 0992553442a..3ca462d4be7 100644
--- a/api/libs/helper.py
+++ b/api/libs/helper.py
@@ -395,7 +395,7 @@ def extract_remote_ip(request: Request) -> str:
if request.headers.get("CF-Connecting-IP"):
return cast(str, request.headers.get("CF-Connecting-IP"))
elif request.headers.getlist("X-Forwarded-For"):
- return cast(str, request.headers.getlist("X-Forwarded-For")[0])
+ return request.headers.getlist("X-Forwarded-For")[0]
else:
return cast(str, request.remote_addr)
diff --git a/api/models/dataset.py b/api/models/dataset.py
index 1432d819486..b062a36d711 100644
--- a/api/models/dataset.py
+++ b/api/models/dataset.py
@@ -919,10 +919,10 @@ class DocumentSegment(TypeBase):
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
dataset_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
document_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
- position: Mapped[int]
+ position: Mapped[int] = mapped_column(sa.Integer, nullable=False)
content: Mapped[str] = mapped_column(LongText, nullable=False)
- word_count: Mapped[int]
- tokens: Mapped[int]
+ word_count: Mapped[int] = mapped_column(sa.Integer, nullable=False)
+ tokens: Mapped[int] = mapped_column(sa.Integer, nullable=False)
created_by: Mapped[str] = mapped_column(StringUUID, nullable=False)
# basic fields
diff --git a/api/providers/trace/trace-aliyun/tests/unit_tests/aliyun_trace/data_exporter/test_traceclient.py b/api/providers/trace/trace-aliyun/tests/unit_tests/aliyun_trace/data_exporter/test_traceclient.py
index 797134b3619..0048c2ea6c0 100644
--- a/api/providers/trace/trace-aliyun/tests/unit_tests/aliyun_trace/data_exporter/test_traceclient.py
+++ b/api/providers/trace/trace-aliyun/tests/unit_tests/aliyun_trace/data_exporter/test_traceclient.py
@@ -56,6 +56,7 @@ class TestTraceClient:
assert client.worker_thread.is_alive()
client.shutdown()
+ # pyrefly: ignore [unnecessary-comparison]
assert client.done is True
@patch("dify_trace_aliyun.data_exporter.traceclient.OTLPSpanExporter")
diff --git a/api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py b/api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py
index 9e3cac2255b..d4436037798 100644
--- a/api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py
+++ b/api/providers/trace/trace-arize-phoenix/tests/unit_tests/arize_phoenix_trace/test_arize_phoenix_trace.py
@@ -36,6 +36,8 @@ from opentelemetry.context import Context
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace import ReadableSpan, Tracer
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, SpanExporter, SpanExportResult
+
+# pyrefly: ignore [deprecated]
from opentelemetry.semconv.trace import SpanAttributes as OTELSpanAttributes
from opentelemetry.trace import NonRecordingSpan, SpanContext, StatusCode, TraceFlags, TraceState, use_span
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
diff --git a/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py b/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
index 98f829d1b7d..9b199b9b982 100644
--- a/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
+++ b/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
@@ -331,6 +331,7 @@ def test_create_and_export_span_exception_logs_error(
client = _build_client()
span = patch_core_components["span"]
span.get_span_context.return_value = _make_span_context(span_id=2)
+ # pyrefly: ignore [missing-attribute]
client.tracer.start_span.side_effect = RuntimeError("boom")
caplog.set_level(logging.DEBUG, logger=client_module.logger.name)
@@ -430,6 +431,7 @@ def test_shutdown_logs_when_meter_provider_fails(caplog: pytest.LogCaptureFixtur
meter_provider = meter_provider_instances[-1]
meter_provider.shutdown.side_effect = RuntimeError("boom")
assert client.metric_reader is not None
+ # pyrefly: ignore [missing-attribute]
client.metric_reader.shutdown.side_effect = RuntimeError("boom")
caplog.set_level(logging.DEBUG, logger=client_module.logger.name)
diff --git a/api/providers/vdb/vdb-oceanbase/tests/integration_tests/bench_oceanbase.py b/api/providers/vdb/vdb-oceanbase/tests/integration_tests/bench_oceanbase.py
index 50f67369425..a6bf8f01c7f 100644
--- a/api/providers/vdb/vdb-oceanbase/tests/integration_tests/bench_oceanbase.py
+++ b/api/providers/vdb/vdb-oceanbase/tests/integration_tests/bench_oceanbase.py
@@ -204,7 +204,9 @@ def main():
# Re-query doc_id from one of the rows we inserted
with client.engine.connect() as conn:
res = conn.execute(text(f"SELECT metadata->>'$.document_id' FROM `{tbl_meta}` LIMIT 1"))
- doc_id_1000 = res.fetchone()[0]
+ res1 = res.fetchone()
+ assert res1 is not None
+ doc_id_1000 = res1[0]
logger.info("\n[Metadata filter query — 1000 rows, by document_id]")
times_no_idx = bench_metadata_query(client, tbl_meta, doc_id_1000, with_index=False)
diff --git a/api/pyproject.toml b/api/pyproject.toml
index 275739ed64e..3cb6ff72c79 100644
--- a/api/pyproject.toml
+++ b/api/pyproject.toml
@@ -183,8 +183,11 @@ dev = [
# "locust>=2.40.4", # Temporarily removed due to compatibility issues. Uncomment when resolved.
"pytest-timeout>=2.4.0",
"pytest-xdist>=3.8.0",
- "pyrefly>=1.0.0",
+ "pyrefly>=1.2.0",
"xinference-client>=2.7.0",
+ "types-pytz>=2026.3.1.20260727",
+ "types-bleach>=6.4.0.20260728",
+ "types-croniter>=6.2.4.20260711",
]
############################################################
@@ -304,4 +307,4 @@ python-platform = "linux"
python-version = "3.12.0"
infer-with-first-use = true
min-severity = "warn"
-errors = { missing-override-decorator = "error" }
+errors = { missing-override-decorator = "error", unnecessary-type-conversion = "info" }
diff --git a/api/services/data_migration/import_service.py b/api/services/data_migration/import_service.py
index 88728faa84f..48ff50ac655 100644
--- a/api/services/data_migration/import_service.py
+++ b/api/services/data_migration/import_service.py
@@ -324,7 +324,7 @@ class MigrationImportService:
options: ImportOptions,
session: Session,
) -> str:
- import_service = AppDslService(cast(Session, session))
+ import_service = AppDslService(session)
if existing_app is not None:
import_result = import_service.import_app(
account=account,
@@ -768,7 +768,7 @@ class MigrationImportService:
report_items.append(ResourceReportItem(ResourceType.MCP_TOOL, existing.id, name, "skipped"))
continue
- service = MCPToolManageService(session=cast(Session, session))
+ service = MCPToolManageService(session=session)
configuration = MCPConfiguration.model_validate(mcp_data.get("configuration") or {})
authentication = (
MCPAuthentication.model_validate(mcp_data["authentication"]) if mcp_data.get("authentication") else None
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py
index 0258ad7e304..bb1b4189e9f 100644
--- a/api/services/dataset_service.py
+++ b/api/services/dataset_service.py
@@ -3314,6 +3314,7 @@ class DocumentService:
# Only set async task and cache if document is currently enabled
if document.enabled:
+ # pyrefly: ignore [bad-assignment]
update_info["async_task"] = {"function": remove_document_from_index_task, "args": [document.id]}
update_info["set_cache"] = True
@@ -3334,6 +3335,7 @@ class DocumentService:
# Only re-index if the document is currently enabled
if document.enabled:
+ # pyrefly: ignore [bad-assignment]
update_info["async_task"] = {"function": add_document_to_index_task, "args": [document.id]}
update_info["set_cache"] = True
diff --git a/api/services/retention/workflow_run/archive_download_preparation.py b/api/services/retention/workflow_run/archive_download_preparation.py
index 510a20a5319..cb9200d23da 100644
--- a/api/services/retention/workflow_run/archive_download_preparation.py
+++ b/api/services/retention/workflow_run/archive_download_preparation.py
@@ -13,7 +13,6 @@ import logging
import re
import zipfile
from collections.abc import Sequence
-from typing import cast
import pyarrow as pa
import pyarrow.compute as pc
@@ -310,7 +309,7 @@ def _validate_manifest(
if not manifest["tables"]:
raise ValueError("manifest tables must not be empty")
for table_name, raw_entry in manifest["tables"].items():
- entry = cast(ArchiveBundleTableManifestEntry, raw_entry)
+ entry = raw_entry
expected_object_key = f"{object_prefix}/{table_name}.parquet"
if entry["object_key"] != expected_object_key:
raise ValueError(
diff --git a/api/tests/test_containers_integration_tests/pyrefly.toml b/api/tests/test_containers_integration_tests/pyrefly.toml
index a02e394465a..6bdd09b3057 100644
--- a/api/tests/test_containers_integration_tests/pyrefly.toml
+++ b/api/tests/test_containers_integration_tests/pyrefly.toml
@@ -141,5 +141,6 @@ project-excludes = [
missing-override-decorator = "error"
redundant-cast = true
unannotated-return = true
-unnecessary-type-conversion = true
unused-ignore = true
+implicit-any-lambda = "info"
+unnecessary-type-conversion = "info"
diff --git a/api/tests/unit_tests/controllers/inner_api/test_agent_tools.py b/api/tests/unit_tests/controllers/inner_api/test_agent_tools.py
index ea53555807e..2a92ecbbc10 100644
--- a/api/tests/unit_tests/controllers/inner_api/test_agent_tools.py
+++ b/api/tests/unit_tests/controllers/inner_api/test_agent_tools.py
@@ -1,6 +1,6 @@
"""Unit tests for the Agent tool inner API controller."""
-from collections.abc import Iterator
+from collections.abc import Generator
from contextlib import contextmanager
from unittest.mock import patch
@@ -46,7 +46,7 @@ def _payload() -> dict[str, object]:
@contextmanager
-def _agent_inner_auth() -> Iterator[None]:
+def _agent_inner_auth() -> Generator[None]:
with (
patch("configs.dify_config.PLUGIN_DAEMON_KEY", "plugin-daemon-key"),
patch("configs.dify_config.INNER_API_KEY_FOR_PLUGIN", "inner-key"),
diff --git a/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_message_end_files.py b/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_message_end_files.py
index c57e84b6f2b..c353fca675f 100644
--- a/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_message_end_files.py
+++ b/api/tests/unit_tests/core/app/task_pipeline/test_easy_ui_message_end_files.py
@@ -169,7 +169,7 @@ class TestMessageEndStreamResponseFiles:
assert file_dict["url"].startswith("https://example.com/signed-url")
assert file_dict["upload_file_id"] == message_file_local.upload_file_id
assert file_dict["remote_url"] == ""
- get_signed_url.assert_called_once_with(upload_file_id=str(upload_file.id))
+ get_signed_url.assert_called_once_with(upload_file_id=upload_file.id)
def test_message_end_with_remote_url(
self, sqlite_session: Session, mock_pipeline: Mock, message_file_remote: MessageFile
diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.toml
index 6181dae49c6..4a2f4e0e0da 100644
--- a/api/tests/unit_tests/pyrefly.toml
+++ b/api/tests/unit_tests/pyrefly.toml
@@ -953,3 +953,5 @@ redundant-cast = true
unannotated-return = true
unnecessary-type-conversion = true
unused-ignore = true
+implicit-any-lambda = "info"
+missing-attribute = "warn"
diff --git a/api/tests/unit_tests/services/retention/workflow_run/test_archive_bundle_index.py b/api/tests/unit_tests/services/retention/workflow_run/test_archive_bundle_index.py
index 0f17f96f571..df26e7a47af 100644
--- a/api/tests/unit_tests/services/retention/workflow_run/test_archive_bundle_index.py
+++ b/api/tests/unit_tests/services/retention/workflow_run/test_archive_bundle_index.py
@@ -130,7 +130,7 @@ def test_backfill_lists_tenant_month_prefix_and_upserts_bundle_index() -> None:
session_factory.return_value.__enter__.return_value = session
backfill = WorkflowRunArchiveBundleIndexBackfill(
storage=cast(MagicMock, storage),
- session_factory=cast(MagicMock, session_factory),
+ session_factory=session_factory,
)
summary = backfill.run(tenant_ids=[TENANT_ID], year=2025, month=3)
@@ -159,7 +159,7 @@ def test_backfill_dry_run_filters_by_year_month_without_database_write() -> None
session_factory = MagicMock()
backfill = WorkflowRunArchiveBundleIndexBackfill(
storage=cast(MagicMock, storage),
- session_factory=cast(MagicMock, session_factory),
+ session_factory=session_factory,
)
summary = backfill.run(tenant_prefixes=["1"], year=2025, month=3, dry_run=True)
diff --git a/api/tests/unit_tests/services/test_batch_indexing_base.py b/api/tests/unit_tests/services/test_batch_indexing_base.py
index 8d07fc30509..21aa6fcce95 100644
--- a/api/tests/unit_tests/services/test_batch_indexing_base.py
+++ b/api/tests/unit_tests/services/test_batch_indexing_base.py
@@ -154,6 +154,7 @@ class TestSendToTenantQueue:
"""When get_task_key() is truthy, tasks must be pushed via push_tasks()."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = "existing-key"
task_func = MagicMock()
@@ -169,6 +170,7 @@ class TestSendToTenantQueue:
"""When a key already exists, task_func.delay must never be called."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = "existing-key"
task_func = MagicMock()
@@ -182,6 +184,7 @@ class TestSendToTenantQueue:
"""When a key already exists, set_task_waiting_time must never be called."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = "existing-key"
task_func = MagicMock()
@@ -196,6 +199,7 @@ class TestSendToTenantQueue:
"""Verify the serialised payload matches asdict(DocumentTask(...))."""
# Arrange
proxy = make_proxy(document_ids=["doc-x"])
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = "k"
task_func = MagicMock()
@@ -219,6 +223,7 @@ class TestSendToTenantQueue:
"""When get_task_key() is falsy, set_task_waiting_time and task_func.delay are invoked."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = None
task_func = MagicMock()
@@ -238,6 +243,7 @@ class TestSendToTenantQueue:
"""When get_task_key() is falsy, push_tasks must never be called."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = None
task_func = MagicMock()
@@ -253,6 +259,7 @@ class TestSendToTenantQueue:
"""Verify that any falsy return from get_task_key() triggers the init branch."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = falsy_key
task_func = MagicMock()
@@ -278,6 +285,7 @@ class TestDispatchRouting:
"""Sandbox plan routes to normal priority queue with tenant isolation."""
# Arrange
proxy = make_proxy()
+ # pyrefly: ignore [missing-attribute]
proxy._tenant_isolated_task_queue.get_task_key.return_value = None
with patch("services.document_indexing_proxy.base.FeatureService.get_features") as mock_features:
diff --git a/api/uv.lock b/api/uv.lock
index cc0061bda8c..02b62946871 100644
--- a/api/uv.lock
+++ b/api/uv.lock
@@ -1403,9 +1403,11 @@ dev = [
{ name = "testcontainers" },
{ name = "types-aiofiles" },
{ name = "types-beautifulsoup4" },
+ { name = "types-bleach" },
{ name = "types-cachetools" },
{ name = "types-cffi" },
{ name = "types-colorama" },
+ { name = "types-croniter" },
{ name = "types-defusedxml" },
{ name = "types-deprecated" },
{ name = "types-docutils" },
@@ -1429,6 +1431,7 @@ dev = [
{ name = "types-pyopenssl" },
{ name = "types-python-dateutil" },
{ name = "types-python-http-client" },
+ { name = "types-pytz" },
{ name = "types-pywin32" },
{ name = "types-pyyaml" },
{ name = "types-redis" },
@@ -1674,7 +1677,7 @@ dev = [
{ name = "lxml-stubs", specifier = ">=0.5.1" },
{ name = "mypy", specifier = ">=1.20.2" },
{ name = "pandas-stubs", specifier = ">=3.0.0" },
- { name = "pyrefly", specifier = ">=1.0.0" },
+ { name = "pyrefly", specifier = ">=1.2.0" },
{ name = "pytest", specifier = ">=9.0.3" },
{ name = "pytest-benchmark", specifier = ">=5.2.3" },
{ name = "pytest-cov", specifier = ">=7.1.0" },
@@ -1687,9 +1690,11 @@ dev = [
{ name = "testcontainers", specifier = ">=4.14.2" },
{ name = "types-aiofiles", specifier = ">=25.1.0" },
{ name = "types-beautifulsoup4", specifier = ">=4.12.0" },
+ { name = "types-bleach", specifier = ">=6.4.0.20260728" },
{ name = "types-cachetools", specifier = ">=7.0.0.20260503" },
{ name = "types-cffi", specifier = ">=2.0.0.20260429" },
{ name = "types-colorama", specifier = ">=0.4.15" },
+ { name = "types-croniter", specifier = ">=6.2.4.20260711" },
{ name = "types-defusedxml", specifier = ">=0.7.0" },
{ name = "types-deprecated", specifier = ">=1.3.1" },
{ name = "types-docutils", specifier = ">=0.22.3" },
@@ -1713,6 +1718,7 @@ dev = [
{ name = "types-pyopenssl", specifier = ">=24.1.0" },
{ name = "types-python-dateutil", specifier = ">=2.9.0" },
{ name = "types-python-http-client", specifier = ">=3.3.7.20260408" },
+ { name = "types-pytz", specifier = ">=2026.3.1.20260727" },
{ name = "types-pywin32", specifier = ">=311.0.0" },
{ name = "types-pyyaml", specifier = ">=6.0.12" },
{ name = "types-redis", specifier = ">=4.6.0.20241004" },
@@ -5450,19 +5456,21 @@ wheels = [
[[package]]
name = "pyrefly"
-version = "1.0.0"
+version = "1.2.0"
source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/9f/3a/9045b0097ac58979c7c30a4fa0e673db942d4adbc7b6d439bd54ae58c441/pyrefly-1.0.0.tar.gz", hash = "sha256:5c2b810ffcebd84be71de5df1223651edee951653a66935c6f091e957c452455", size = 5677995, upload-time = "2026-05-12T20:12:46.812Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/89/01/a86e9f24722b095c3f88e3616132b75a21b0df53804bdc6a45314dd4d93c/pyrefly-1.2.0.tar.gz", hash = "sha256:5485f960fc2481617068c918335c39ab1507ef90b6b5bd35bf57726e60e73185", size = 6243654, upload-time = "2026-08-01T02:56:27.592Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/f4/c6/90788819bac9c61dd7bacba53b79f3c12d47ccbe5e51b3d6d89f2387e1d2/pyrefly-1.0.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e355a0908555348ed4b9585ef25c76ff566673e345c866c325f1633f44d890b6", size = 13122950, upload-time = "2026-05-12T20:12:20.711Z" },
- { url = "https://files.pythonhosted.org/packages/82/91/a3cf2a1e87d336eaa804a1e6fc93266faf6dc2a97eecdbc7eae289628022/pyrefly-1.0.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:a7038efc3a40f8294edee339895633cf22db268c0d434cdbcbefc34f78a9ecc3", size = 12599494, upload-time = "2026-05-12T20:12:23.495Z" },
- { url = "https://files.pythonhosted.org/packages/cd/ab/74d1e11e737e99b1c003ecc5d7d2e846c4ea1f328966bfdbbd0ac63fad0a/pyrefly-1.0.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:da331ca515ed1c08791da2b5f664cf9c1294c48fd802133262e7d5d51e0f4416", size = 12995507, upload-time = "2026-05-12T20:12:25.951Z" },
- { url = "https://files.pythonhosted.org/packages/7c/ac/2df0899f8464c97e5d995f994c97c5cb5b0f58610432aa90d26d924e1db5/pyrefly-1.0.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c74219d8f3e63cdaa5501a0b21d1c9d37011820f9606728d0ed06f09ae86a878", size = 13947693, upload-time = "2026-05-12T20:12:29.188Z" },
- { url = "https://files.pythonhosted.org/packages/6b/3e/b247c24321e36f04b7d51f9ccf3df93e5009e4b29939524b36ec2e17dc2a/pyrefly-1.0.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c0d05543b1bb6ee6d64149eb5d6b2fb15aa72d3962d6a97abca0afaca8b0c131", size = 13925803, upload-time = "2026-05-12T20:12:31.904Z" },
- { url = "https://files.pythonhosted.org/packages/61/16/cfa2d61a4aa1e1f7bca48bb37acd01c6a09db4864b16a54f9587092765ff/pyrefly-1.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1382d5b1fcdb49a4de9f34d112d2bddf290a78ff93ee8149492ad5f1077ddffc", size = 13470398, upload-time = "2026-05-12T20:12:35.302Z" },
- { url = "https://files.pythonhosted.org/packages/cb/2b/6372c7dddb326223e24a46b17efd0d4bd7b4fe22c821e523157577eed2d2/pyrefly-1.0.0-py3-none-win32.whl", hash = "sha256:aa8b5d0e47080e3202a2547b39f7a5a61d2c781c712b3b67884f745ca2c759d2", size = 12222643, upload-time = "2026-05-12T20:12:38.618Z" },
- { url = "https://files.pythonhosted.org/packages/be/ad/1d23be700b6b2ddaeb362360c7145917a8edbbf7240ae428d40541772fce/pyrefly-1.0.0-py3-none-win_amd64.whl", hash = "sha256:c8abcb0f2082e83c890375128f9cff4aa4d3f210b85eea7b3046c1ae764e77f5", size = 13146369, upload-time = "2026-05-12T20:12:41.423Z" },
- { url = "https://files.pythonhosted.org/packages/8c/38/16589134f3012fd097a10dcc85771555f1a5fb76e04b682597180743af30/pyrefly-1.0.0-py3-none-win_arm64.whl", hash = "sha256:d150fa9e40e8392832be81c3bcfc0497c146674ce4d0f8e04e1ec29e775ffb8c", size = 12538326, upload-time = "2026-05-12T20:12:43.996Z" },
+ { url = "https://files.pythonhosted.org/packages/7d/9d/3c0ef1d4843987b22f996ed381ec9cf5a3b1273e29804db276252e4c95eb/pyrefly-1.2.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:7f46d983ac49ddd2b043694960a01dc6a19a5cfd8eec609d6bd9c42866f91b4e", size = 14026305, upload-time = "2026-08-01T02:56:02.611Z" },
+ { url = "https://files.pythonhosted.org/packages/0a/06/03bbb78fbea54cdc65b626619f3597d5611aca4fdef11e72a4e8360e7e63/pyrefly-1.2.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:756f669b5555090f5c1a4fef30db1785fabe657764f7e4e6dc88994dfb8ca82d", size = 13463880, upload-time = "2026-08-01T02:56:04.93Z" },
+ { url = "https://files.pythonhosted.org/packages/13/5a/7d8bc00a38e93bbc9c3e7bd14d305f7948717e667c9bcddeab9dd42fd255/pyrefly-1.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3465812ce5ef4781fb592edbf2724547296f0a3124be115d73c7e8b2401862d", size = 13907329, upload-time = "2026-08-01T02:56:07.104Z" },
+ { url = "https://files.pythonhosted.org/packages/be/94/9e08b4bf799d0b8f36b55a2783c7ba5f51730cf0632a85a67b5b5ed876cd/pyrefly-1.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5de7b2ad2bba5c8055181681a84b74143eac2234a48ba5d1b7ed7e7a722b02bd", size = 15039020, upload-time = "2026-08-01T02:56:09.208Z" },
+ { url = "https://files.pythonhosted.org/packages/5b/bd/bca5fd0c80f4daf8ee6903a29df9f3de1feb05ff0946b8f35ec8c5096b13/pyrefly-1.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:25822ea9505f589ea8a725e4268b475132fb89e038fbf092e446510443ac142a", size = 14986199, upload-time = "2026-08-01T02:56:11.924Z" },
+ { url = "https://files.pythonhosted.org/packages/97/f7/f07087f3d185ad2eced0c56cef89ca5474dfb4ff25f146cd50a861c97553/pyrefly-1.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90efe75e17491ef5d636e10469e9278d7d0256b3b4c5e1f4750069bf3ae0f5d1", size = 14393715, upload-time = "2026-08-01T02:56:14.143Z" },
+ { url = "https://files.pythonhosted.org/packages/d3/70/0d142c320e284b9e3ce35e9b1e58b8ce2ee1f578f2a7234bc30e5022b94f/pyrefly-1.2.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:368aaf7eee4f511ddc0f8e564cf14e01ab2f10b0db9105c6d5b153bf498d07bf", size = 13933008, upload-time = "2026-08-01T02:56:16.525Z" },
+ { url = "https://files.pythonhosted.org/packages/5d/e8/e84f11b6e1f63fd453ad3654213b9a0f6f4de8cef6b58038eef2d0d5955d/pyrefly-1.2.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d52d5da7bc65fb7675fbaa80eda879d4f8787c494f04cac21603330d3abbdbbe", size = 14431827, upload-time = "2026-08-01T02:56:18.645Z" },
+ { url = "https://files.pythonhosted.org/packages/0f/06/810d31380f66c75e1c0779a408d3b16117b1b368b57894f6aa66bef21686/pyrefly-1.2.0-py3-none-win32.whl", hash = "sha256:8c90751de8506d938e8f802659c74cf35bd7a0036510ee6c634a38eebb280bfa", size = 13229447, upload-time = "2026-08-01T02:56:20.921Z" },
+ { url = "https://files.pythonhosted.org/packages/ed/98/4dafa3c7a1caed2dc8cc708dde09ba27963c7736508f55b626fff3024113/pyrefly-1.2.0-py3-none-win_amd64.whl", hash = "sha256:8a8964c224ccc4882730130955815de21ff443c1ac3f0b90685b19bf63848170", size = 14087387, upload-time = "2026-08-01T02:56:23.188Z" },
+ { url = "https://files.pythonhosted.org/packages/1b/1c/df3cb0a2e5591660ded7a1836cd2f29dc48c91adb1c0a3a700a96f6d09e1/pyrefly-1.2.0-py3-none-win_arm64.whl", hash = "sha256:3a90bb8df39dfbac74b1f3b2e9d7c526b8f80568884c3944d955023a73ebf61e", size = 13430873, upload-time = "2026-08-01T02:56:25.425Z" },
]
[[package]]
@@ -6652,6 +6660,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/7c/79/d84de200a80085b32f12c5820d4fd0addcbe7ba6dce8c1c9d8605e833c8e/types_beautifulsoup4-4.12.0.20250516-py3-none-any.whl", hash = "sha256:5923399d4a1ba9cc8f0096fe334cc732e130269541d66261bb42ab039c0376ee", size = 16879, upload-time = "2025-05-16T03:09:09.051Z" },
]
+[[package]]
+name = "types-bleach"
+version = "6.4.0.20260728"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "types-html5lib" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/c0/58/b9f2678dd538de3aa8613825986dab68608447a25bd32aa336e65a6e2cdc/types_bleach-6.4.0.20260728.tar.gz", hash = "sha256:526a4fec997514bf3fe989ef59b86ec694bbb2ed70db22c59b622eb5a9b80fae", size = 11785, upload-time = "2026-07-28T04:52:17.359Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/3c/3d/ac2809b7afe8ac7c907faacdd60bd3d194de0802d809b82327e969bc05da/types_bleach-6.4.0.20260728-py3-none-any.whl", hash = "sha256:ea9feed53196b24a6d9f0cb471c1cfbb0788b3194e8335dc8da1b951b4965d7f", size = 12012, upload-time = "2026-07-28T04:52:16.344Z" },
+]
+
[[package]]
name = "types-cachetools"
version = "7.0.0.20260503"
@@ -6682,6 +6702,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/b9/65/d03948be8ae9362ad26f36443eab051fe5524295fe008126cd65792f9833/types_colorama-0.4.15.20260408-py3-none-any.whl", hash = "sha256:7327a51c760d94f7df2e8c72c275a4468c03c3abb606d23995cb37e3d24d9132", size = 10763, upload-time = "2026-04-08T04:28:30.688Z" },
]
+[[package]]
+name = "types-croniter"
+version = "6.2.4.20260711"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/c0/e1/ef8900515a103efa41b29ce81e59efb18e72bc9642139c5a3a17f6022641/types_croniter-6.2.4.20260711.tar.gz", hash = "sha256:807793e109f4e0d51ec18f6277a1a5f1d133e425ac6bee3a7c3254ab1793e0ea", size = 12164, upload-time = "2026-07-11T04:51:18.624Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/c8/3f/896a98180a55f855bd068b97e8c99fd4ce1885a4b43f68fd7b29641084f6/types_croniter-6.2.4.20260711-py3-none-any.whl", hash = "sha256:601b68139a47fe1b2177f433132cc81fd91155f3059a49c5cb63404c389dff01", size = 9746, upload-time = "2026-07-11T04:51:17.662Z" },
+]
+
[[package]]
name = "types-defusedxml"
version = "0.7.0.20260408"
@@ -6910,6 +6939,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/f1/d8/45c6c04924086e8856e7f9a33a38ee713992d9ae9cd6d449de97badcba3c/types_python_http_client-3.3.7.20260408-py3-none-any.whl", hash = "sha256:3f310282e0fe2a18c5291f935538e1f97b9f80d2c5571aad155e66806719017c", size = 8851, upload-time = "2026-04-08T04:27:08.877Z" },
]
+[[package]]
+name = "types-pytz"
+version = "2026.3.1.20260727"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/b1/cf/eae96172a036b942e0ad0ec49512108b4ef4b97cd6c2aed5677540a597e7/types_pytz-2026.3.1.20260727.tar.gz", hash = "sha256:4364075b6867dd15b210bb8c1d29727d609917129b45600defe1d4b3eda5ecb9", size = 10914, upload-time = "2026-07-27T05:36:32.389Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/9c/24/a654176875944981c75516857cd8750600eeb9ff7fc07a2b82573619a57c/types_pytz-2026.3.1.20260727-py3-none-any.whl", hash = "sha256:42ac44e83645bfceb46597342c8fb8ec028a1407e2feae9c5c539986eab6b57a", size = 10132, upload-time = "2026-07-27T05:36:31.52Z" },
+]
+
[[package]]
name = "types-pywin32"
version = "311.0.0.20260408"