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.

ci: enable Ruff B006 (#44099)

Asuka Minatof2033a4fc995
diff --git a/api/.ruff.toml b/api/.ruff.toml
index 6a976f5e570..c13e0fe4ff0 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -68,7 +68,6 @@ ignore = [
"FURB152", # math-constant
"UP007", # non-pep604-annotation
"UP032", # f-string
- "B006", # mutable-argument-default
"B007", # unused-loop-control-variable
"B026", # star-arg-unpacking-after-keyword-arg
"B901", # allow return in yield
diff --git a/api/core/rag/extractor/notion_extractor.py b/api/core/rag/extractor/notion_extractor.py
index 680b049a9ea..bffeca3721f 100644
--- a/api/core/rag/extractor/notion_extractor.py
+++ b/api/core/rag/extractor/notion_extractor.py
@@ -1,7 +1,8 @@
import json
import logging
import operator
-from collections.abc import Callable
+from collections.abc import Callable, Mapping
+from types import MappingProxyType
from typing import Any, cast, override
import httpx
@@ -79,7 +80,9 @@ class NotionExtractor(BaseExtractor):
return docs
- def _get_notion_database_data(self, database_id: str, query_dict: dict[str, Any] = {}) -> list[Document]:
+ def _get_notion_database_data(
+ self, database_id: str, query_dict: Mapping[str, Any] = MappingProxyType({})
+ ) -> list[Document]:
"""Get all the pages from a Notion database."""
assert self._notion_access_token is not None, "Notion access token is required"
@@ -88,7 +91,7 @@ class NotionExtractor(BaseExtractor):
has_more = True
while has_more:
- current_query = query_dict.copy()
+ current_query = dict(query_dict)
if next_cursor:
current_query["start_cursor"] = next_cursor
@@ -158,7 +161,7 @@ class NotionExtractor(BaseExtractor):
start_cursor = None
block_url = BLOCK_CHILD_URL_TMPL.format(block_id=page_id)
while True:
- query_dict: dict[str, Any] = {} if not start_cursor else {"start_cursor": start_cursor}
+ query_dict: Mapping[str, Any] = MappingProxyType({}) if not start_cursor else {"start_cursor": start_cursor}
try:
res = httpx.request(
"GET",
@@ -220,7 +223,7 @@ class NotionExtractor(BaseExtractor):
start_cursor = None
block_url = BLOCK_CHILD_URL_TMPL.format(block_id=block_id)
while True:
- query_dict: dict[str, Any] = {} if not start_cursor else {"start_cursor": start_cursor}
+ query_dict: Mapping[str, Any] = MappingProxyType({}) if not start_cursor else {"start_cursor": start_cursor}
res = httpx.request(
"GET",
@@ -287,7 +290,7 @@ class NotionExtractor(BaseExtractor):
start_cursor = None
block_url = BLOCK_CHILD_URL_TMPL.format(block_id=block_id)
while not done:
- query_dict: dict[str, Any] = {} if not start_cursor else {"start_cursor": start_cursor}
+ query_dict: Mapping[str, Any] = MappingProxyType({}) if not start_cursor else {"start_cursor": start_cursor}
res = httpx.request(
"GET",
@@ -358,7 +361,7 @@ class NotionExtractor(BaseExtractor):
else:
retrieve_page_url = RETRIEVE_PAGE_URL_TMPL.format(page_id=obj_id)
- query_dict: dict[str, Any] = {}
+ query_dict: Mapping[str, Any] = MappingProxyType({})
res = httpx.request(
"GET",
diff --git a/api/services/plugin/oauth_service.py b/api/services/plugin/oauth_service.py
index 789b5fa5b77..b4f3f798bd8 100644
--- a/api/services/plugin/oauth_service.py
+++ b/api/services/plugin/oauth_service.py
@@ -1,5 +1,7 @@
import json
import uuid
+from collections.abc import Mapping
+from types import MappingProxyType
from typing import Any
from core.plugin.impl.base import BasePluginClient
@@ -17,7 +19,7 @@ class OAuthProxyService(BasePluginClient):
tenant_id: str,
plugin_id: str,
provider: str,
- extra_data: dict[str, Any] = {},
+ extra_data: Mapping[str, Any] = MappingProxyType({}),
credential_id: str | None = None,
):
"""