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 E712 (#44114)

Asuka Minatoa4e0a0c10d39
diff --git a/api/.ruff.toml b/api/.ruff.toml
index 608e39c7c1b..7d5d0185f24 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -59,7 +59,6 @@ select = [
ignore = [
"E402", # module-import-not-at-top-of-file
- "E712", # true-false-comparison
"F821", # undefined-name
"F841", # unused-variable
"UP007", # non-pep604-annotation
diff --git a/api/commands/vector.py b/api/commands/vector.py
index d0555332e5e..1ff274f13ce 100644
--- a/api/commands/vector.py
+++ b/api/commands/vector.py
@@ -252,8 +252,8 @@ def migrate_knowledge_vector_database():
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset.id,
DatasetDocument.indexing_status == IndexingStatus.COMPLETED,
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
@@ -264,7 +264,7 @@ def migrate_knowledge_vector_database():
select(DocumentSegment).where(
DocumentSegment.document_id == dataset_document.id,
DocumentSegment.status == SegmentStatus.COMPLETED,
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
).all()
diff --git a/api/core/provider_manager.py b/api/core/provider_manager.py
index 1602a8055b1..0da6ef13764 100644
--- a/api/core/provider_manager.py
+++ b/api/core/provider_manager.py
@@ -460,7 +460,7 @@ def _attach_active_credentials(
def _load_provider_model_cache_entries(tenant_id: str) -> list[_ProviderModelCacheEntry]:
with session_factory.create_session() as session:
- stmt = select(ProviderModel).where(ProviderModel.tenant_id == tenant_id, ProviderModel.is_valid == True)
+ stmt = select(ProviderModel).where(ProviderModel.tenant_id == tenant_id, ProviderModel.is_valid.is_(True))
provider_models = list(session.scalars(stmt))
_attach_active_credentials(
session=session,
@@ -1002,7 +1002,7 @@ class ProviderManager:
def _get_all_providers(tenant_id: str) -> dict[str, list[Provider]]:
provider_name_to_provider_records_dict = defaultdict(list)
with session_factory.create_session() as session:
- stmt = select(Provider).where(Provider.tenant_id == tenant_id, Provider.is_valid == True)
+ stmt = select(Provider).where(Provider.tenant_id == tenant_id, Provider.is_valid.is_(True))
providers = list(session.scalars(stmt))
_attach_active_credentials(
session=session,
diff --git a/api/core/rag/datasource/retrieval_service.py b/api/core/rag/datasource/retrieval_service.py
index e97984d4291..144f63af9e8 100644
--- a/api/core/rag/datasource/retrieval_service.py
+++ b/api/core/rag/datasource/retrieval_service.py
@@ -603,7 +603,7 @@ class RetrievalService:
if index_node_ids:
document_segment_stmt = select(DocumentSegment).where(
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegment.status == "completed",
DocumentSegment.index_node_id.in_(index_node_ids),
)
@@ -614,7 +614,7 @@ class RetrievalService:
if segment_ids:
document_segment_stmt = select(DocumentSegment).where(
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegment.status == "completed",
DocumentSegment.id.in_(segment_ids),
)
@@ -627,7 +627,7 @@ class RetrievalService:
if summary_segment_ids:
summary_segment_ids_list = list(summary_segment_ids)
summary_segment_stmt = select(DocumentSegment).where(
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegment.status == "completed",
DocumentSegment.id.in_(summary_segment_ids_list),
)
diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.py
index abe451ffb01..04a13af66a8 100644
--- a/api/core/rag/retrieval/dataset_retrieval.py
+++ b/api/core/rag/retrieval/dataset_retrieval.py
@@ -601,8 +601,8 @@ class DatasetRetrieval:
document_ids = [record.segment.document_id for record in authorized_records]
dataset_document_stmt = select(DatasetDocument).where(
DatasetDocument.id.in_(document_ids),
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
documents = session.execute(dataset_document_stmt).scalars().all() # type: ignore
dataset_stmt = select(Dataset).where(
@@ -1527,8 +1527,8 @@ class DatasetRetrieval:
document_query = select(DatasetDocument).where(
DatasetDocument.dataset_id.in_(dataset_ids),
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
filters = [] # type: ignore
metadata_condition = None
@@ -2081,8 +2081,8 @@ class DatasetRetrieval:
select(DocumentModel.dataset_id, func.count(DocumentModel.id).label("available_document_count"))
.where(
DocumentModel.indexing_status == "completed",
- DocumentModel.enabled == True,
- DocumentModel.archived == False,
+ DocumentModel.enabled.is_(True),
+ DocumentModel.archived.is_(False),
DocumentModel.dataset_id.in_(dataset_ids),
)
.group_by(DocumentModel.dataset_id)
diff --git a/api/core/rag/summary_index/summary_index.py b/api/core/rag/summary_index/summary_index.py
index 81fe9a1be73..63daf80f015 100644
--- a/api/core/rag/summary_index/summary_index.py
+++ b/api/core/rag/summary_index/summary_index.py
@@ -47,7 +47,7 @@ class SummaryIndex:
DocumentSegment.dataset_id == dataset_id,
DocumentSegment.document_id == document_id,
DocumentSegment.status == "completed",
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
).all()
segment_ids = [segment.id for segment in segments]
diff --git a/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
index 83b400f7eb1..909381f8804 100644
--- a/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
+++ b/api/core/tools/utils/dataset_retriever/dataset_multi_retriever_tool.py
@@ -94,7 +94,7 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
DocumentSegment.dataset_id.in_(self.dataset_ids),
DocumentSegment.completed_at.isnot(None),
DocumentSegment.status == "completed",
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegment.index_node_id.in_(index_node_ids),
)
segments = session.scalars(document_segment_stmt).all()
@@ -117,8 +117,8 @@ class DatasetMultiRetrieverTool(DatasetRetrieverBaseTool):
dataset = session.get(Dataset, segment.dataset_id)
document_stmt = select(Document).where(
Document.id == segment.document_id,
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
)
document = session.scalar(document_stmt)
if dataset and document:
diff --git a/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py b/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py
index ff0a1c16930..715ab7453a0 100644
--- a/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py
+++ b/api/core/tools/utils/dataset_retriever/dataset_retriever_tool.py
@@ -201,8 +201,8 @@ class DatasetRetrieverTool(DatasetRetrieverBaseTool):
dataset = session.get(Dataset, segment.dataset_id)
dataset_document_stmt = select(DatasetDocument).where(
DatasetDocument.id == segment.document_id,
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
document = session.scalar(dataset_document_stmt)
if dataset and document:
diff --git a/api/providers/vdb/vdb-tidb-on-qdrant/src/dify_vdb_tidb_on_qdrant/tidb_on_qdrant_vector.py b/api/providers/vdb/vdb-tidb-on-qdrant/src/dify_vdb_tidb_on_qdrant/tidb_on_qdrant_vector.py
index bdedfc69266..32347824f2c 100644
--- a/api/providers/vdb/vdb-tidb-on-qdrant/src/dify_vdb_tidb_on_qdrant/tidb_on_qdrant_vector.py
+++ b/api/providers/vdb/vdb-tidb-on-qdrant/src/dify_vdb_tidb_on_qdrant/tidb_on_qdrant_vector.py
@@ -457,7 +457,7 @@ class TidbOnQdrantVectorFactory(AbstractVectorFactory):
else:
idle_tidb_auth_binding = db.session.scalar(
select(TidbAuthBinding)
- .where(TidbAuthBinding.active == False, TidbAuthBinding.status == "ACTIVE")
+ .where(TidbAuthBinding.active.is_(False), TidbAuthBinding.status == "ACTIVE")
.limit(1)
)
if idle_tidb_auth_binding:
diff --git a/api/repositories/app/console_repository.py b/api/repositories/app/console_repository.py
index 65c1f0c9101..bffca439feb 100644
--- a/api/repositories/app/console_repository.py
+++ b/api/repositories/app/console_repository.py
@@ -358,7 +358,7 @@ class ConsoleAppRepository(ConsoleApps, DiscoveryApps, RelatedApps):
def _build_app_list_filters(
user_id: str, tenant_id: str, params: AppListBaseParams, session: Session
) -> list[sa.ColumnElement[bool]]:
- filters = [App.tenant_id == tenant_id, App.is_universal == False]
+ filters = [App.tenant_id == tenant_id, App.is_universal.is_(False)]
if params.mode == "workflow":
filters.append(App.mode == AppMode.WORKFLOW)
diff --git a/api/repositories/knowledge/dataset_read_repository.py b/api/repositories/knowledge/dataset_read_repository.py
index c7e2c8a5f43..6a0b837bcb7 100644
--- a/api/repositories/knowledge/dataset_read_repository.py
+++ b/api/repositories/knowledge/dataset_read_repository.py
@@ -322,8 +322,8 @@ def get_dataset_available_document_count(dataset: Dataset, *, session: Session)
Document.dataset_id == dataset.id,
Document.tenant_id == dataset.tenant_id,
Document.indexing_status == "completed",
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
)
)
or 0
@@ -337,7 +337,7 @@ def get_dataset_available_segment_count(dataset: Dataset, *, session: Session) -
DocumentSegment.dataset_id == dataset.id,
DocumentSegment.tenant_id == dataset.tenant_id,
DocumentSegment.status == "completed",
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
)
or 0
@@ -629,8 +629,8 @@ def build_dataset_detail_prefetch(datasets: Sequence[Dataset], *, session: Sessi
(
sa.and_(
Document.indexing_status == "completed",
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
),
1,
),
diff --git a/api/schedule/clean_unused_datasets_task.py b/api/schedule/clean_unused_datasets_task.py
index 9b4ae74070c..45f4aca4e56 100644
--- a/api/schedule/clean_unused_datasets_task.py
+++ b/api/schedule/clean_unused_datasets_task.py
@@ -56,8 +56,8 @@ def clean_unused_datasets_task():
select(Document.dataset_id, func.count(Document.id).label("document_count"))
.where(
Document.indexing_status == "completed",
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
Document.updated_at > clean_day,
)
.group_by(Document.dataset_id)
@@ -69,8 +69,8 @@ def clean_unused_datasets_task():
select(Document.dataset_id, func.count(Document.id).label("document_count"))
.where(
Document.indexing_status == "completed",
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
Document.updated_at < clean_day,
)
.group_by(Document.dataset_id)
@@ -127,8 +127,8 @@ def clean_unused_datasets_task():
documents = session.scalars(
select(Document).where(
Document.dataset_id == dataset.id,
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
)
).all()
for document in documents:
diff --git a/api/schedule/create_tidb_serverless_task.py b/api/schedule/create_tidb_serverless_task.py
index e242b0c667a..bf0b71a9ba0 100644
--- a/api/schedule/create_tidb_serverless_task.py
+++ b/api/schedule/create_tidb_serverless_task.py
@@ -22,7 +22,7 @@ def create_tidb_serverless_task():
try:
# check the number of idle tidb serverless
idle_tidb_serverless_number = (
- db.session.scalar(select(func.count(TidbAuthBinding.id)).where(TidbAuthBinding.active == False)) or 0
+ db.session.scalar(select(func.count(TidbAuthBinding.id)).where(TidbAuthBinding.active.is_(False))) or 0
)
if idle_tidb_serverless_number >= tidb_serverless_number:
break
diff --git a/api/schedule/update_tidb_serverless_status_task.py b/api/schedule/update_tidb_serverless_status_task.py
index 46d1b85aa0c..57387ab9011 100644
--- a/api/schedule/update_tidb_serverless_status_task.py
+++ b/api/schedule/update_tidb_serverless_status_task.py
@@ -20,7 +20,7 @@ def update_tidb_serverless_status_task():
# check the number of idle tidb serverless
tidb_serverless_list = db.session.scalars(
select(TidbAuthBinding).where(
- TidbAuthBinding.active == False,
+ TidbAuthBinding.active.is_(False),
TidbAuthBinding.status == TidbAuthBindingStatus.CREATING,
)
).all()
diff --git a/api/services/app_service.py b/api/services/app_service.py
index bfbc32ca50b..5d5ce4a0825 100644
--- a/api/services/app_service.py
+++ b/api/services/app_service.py
@@ -223,7 +223,7 @@ class AppService:
def _build_app_list_filters(
user_id: str, tenant_id: str, params: AppListBaseParams, session: Session
) -> list[sa.ColumnElement[bool]]:
- filters = [App.tenant_id == tenant_id, App.is_universal == False]
+ filters = [App.tenant_id == tenant_id, App.is_universal.is_(False)]
if params.mode == "workflow":
filters.append(App.mode == AppMode.WORKFLOW)
diff --git a/api/services/conversation_service.py b/api/services/conversation_service.py
index 3842841136b..a87cba2013b 100644
--- a/api/services/conversation_service.py
+++ b/api/services/conversation_service.py
@@ -49,7 +49,7 @@ class ConversationService:
return InfiniteScrollPagination(data=[], limit=limit, has_more=False)
stmt = select(Conversation).where(
- Conversation.is_deleted == False,
+ Conversation.is_deleted.is_(False),
Conversation.app_id == app_model.id,
Conversation.from_source == ("api" if isinstance(user, EndUser) else "console"),
Conversation.from_end_user_id == (user.id if isinstance(user, EndUser) else None),
@@ -183,7 +183,7 @@ class ConversationService:
Conversation.from_source == ("api" if isinstance(user, EndUser) else "console"),
Conversation.from_end_user_id == (user.id if isinstance(user, EndUser) else None),
Conversation.from_account_id == (user.id if isinstance(user, Account) else None),
- Conversation.is_deleted == False,
+ Conversation.is_deleted.is_(False),
)
.limit(1)
)
diff --git a/api/services/data_source/provider_service.py b/api/services/data_source/provider_service.py
index 81accea97de..8915337f443 100644
--- a/api/services/data_source/provider_service.py
+++ b/api/services/data_source/provider_service.py
@@ -453,7 +453,7 @@ class DatasourceProviderService:
DatasourceOauthTenantParamConfig.tenant_id == tenant_id,
DatasourceOauthTenantParamConfig.provider == datasource_provider_id.provider_name,
DatasourceOauthTenantParamConfig.plugin_id == datasource_provider_id.plugin_id,
- DatasourceOauthTenantParamConfig.enabled == True,
+ DatasourceOauthTenantParamConfig.enabled.is_(True),
)
)
or 0
diff --git a/api/services/knowledge/dataset_service.py b/api/services/knowledge/dataset_service.py
index 045d817b021..5c1c4d80682 100644
--- a/api/services/knowledge/dataset_service.py
+++ b/api/services/knowledge/dataset_service.py
@@ -1834,9 +1834,9 @@ class DocumentService:
Document.tenant_id == dataset_ref.tenant_id,
Document.dataset_id == dataset_ref.dataset_id,
Document.id.in_(document_ids),
- Document.enabled == True,
+ Document.enabled.is_(True),
Document.indexing_status == IndexingStatus.COMPLETED,
- Document.archived == False,
+ Document.archived.is_(False),
)
).all()
return documents
@@ -1846,7 +1846,7 @@ class DocumentService:
documents = session.scalars(
select(Document).where(
Document.dataset_id == dataset_id,
- Document.enabled == True,
+ Document.enabled.is_(True),
)
).all()
@@ -1857,9 +1857,9 @@ class DocumentService:
documents = session.scalars(
select(Document).where(
Document.dataset_id == dataset_id,
- Document.enabled == True,
+ Document.enabled.is_(True),
Document.indexing_status == IndexingStatus.COMPLETED,
- Document.archived == False,
+ Document.archived.is_(False),
)
).all()
@@ -2401,7 +2401,7 @@ class DocumentService:
Document.dataset_id == dataset.id,
Document.tenant_id == account.current_tenant_id,
Document.data_source_type == DataSourceType.UPLOAD_FILE,
- Document.enabled == True,
+ Document.enabled.is_(True),
Document.name.in_(file_names),
)
).all()
@@ -2456,7 +2456,7 @@ class DocumentService:
Document.dataset_id == dataset.id,
Document.tenant_id == account.current_tenant_id,
Document.data_source_type == DataSourceType.NOTION_IMPORT,
- Document.enabled == True,
+ Document.enabled.is_(True),
)
).all()
)
@@ -2902,8 +2902,8 @@ class DocumentService:
session.scalar(
select(func.count(Document.id)).where(
Document.completed_at.isnot(None),
- Document.enabled == True,
- Document.archived == False,
+ Document.enabled.is_(True),
+ Document.archived.is_(False),
Document.tenant_id == current_user.current_tenant_id,
)
)
@@ -3003,7 +3003,7 @@ class DocumentService:
sa.and_(
DataSourceOauthBinding.tenant_id == account.current_tenant_id,
DataSourceOauthBinding.provider == "notion",
- DataSourceOauthBinding.disabled == False,
+ DataSourceOauthBinding.disabled.is_(False),
DataSourceOauthBinding.source_info["workspace_id"] == f'"{workspace_id}"',
)
)
diff --git a/api/services/rag_pipeline/rag_pipeline.py b/api/services/rag_pipeline/rag_pipeline.py
index 833732b77ff..a2743db07b0 100644
--- a/api/services/rag_pipeline/rag_pipeline.py
+++ b/api/services/rag_pipeline/rag_pipeline.py
@@ -1467,7 +1467,7 @@ class RagPipelineService:
def get_recommended_plugins(self, type: str, current_user: Account, current_tenant_id: str) -> dict[str, Any]:
# Query active recommended plugins
- stmt = select(PipelineRecommendedPlugin).where(PipelineRecommendedPlugin.active == True)
+ stmt = select(PipelineRecommendedPlugin).where(PipelineRecommendedPlugin.active.is_(True))
if type and type != "all":
stmt = stmt.where(PipelineRecommendedPlugin.type == type)
diff --git a/api/tasks/deal_dataset_index_update_task.py b/api/tasks/deal_dataset_index_update_task.py
index 5103e4ad494..30e79109373 100644
--- a/api/tasks/deal_dataset_index_update_task.py
+++ b/api/tasks/deal_dataset_index_update_task.py
@@ -40,8 +40,8 @@ def deal_dataset_index_update_task(dataset_id: str, action: str):
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset_id,
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
@@ -61,7 +61,7 @@ def deal_dataset_index_update_task(dataset_id: str, action: str):
select(DocumentSegment)
.where(
DocumentSegment.document_id == dataset_document.id,
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
.order_by(DocumentSegment.position.asc())
).all()
@@ -107,8 +107,8 @@ def deal_dataset_index_update_task(dataset_id: str, action: str):
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset_id,
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
# add new index
@@ -134,7 +134,7 @@ def deal_dataset_index_update_task(dataset_id: str, action: str):
select(DocumentSegment)
.where(
DocumentSegment.document_id == dataset_document.id,
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
.order_by(DocumentSegment.position.asc())
).all()
diff --git a/api/tasks/deal_dataset_vector_index_task.py b/api/tasks/deal_dataset_vector_index_task.py
index 46527bb46fe..cd9ac5014f9 100644
--- a/api/tasks/deal_dataset_vector_index_task.py
+++ b/api/tasks/deal_dataset_vector_index_task.py
@@ -44,8 +44,8 @@ def deal_dataset_vector_index_task(dataset_id: str, action: str):
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset_id,
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
@@ -65,7 +65,7 @@ def deal_dataset_vector_index_task(dataset_id: str, action: str):
select(DocumentSegment)
.where(
DocumentSegment.document_id == dataset_document.id,
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
.order_by(DocumentSegment.position.asc())
).all()
@@ -103,8 +103,8 @@ def deal_dataset_vector_index_task(dataset_id: str, action: str):
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset_id,
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
# add new index
@@ -130,7 +130,7 @@ def deal_dataset_vector_index_task(dataset_id: str, action: str):
select(DocumentSegment)
.where(
DocumentSegment.document_id == dataset_document.id,
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
)
.order_by(DocumentSegment.position.asc())
).all()
diff --git a/api/tasks/regenerate_summary_index_task.py b/api/tasks/regenerate_summary_index_task.py
index 2d89aca647a..26d523dfe43 100644
--- a/api/tasks/regenerate_summary_index_task.py
+++ b/api/tasks/regenerate_summary_index_task.py
@@ -101,7 +101,7 @@ def regenerate_summary_index_task(
.where(
DocumentSegment.dataset_id == dataset_id,
DocumentSegment.status == "completed", # Segment must be completed
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegmentSummary.dataset_id == dataset_id,
DocumentSegmentSummary.summary_content.isnot(None), # Must have summary content
# Include completed summaries or error summaries (with content)
@@ -109,8 +109,8 @@ def regenerate_summary_index_task(
DocumentSegmentSummary.status == SummaryStatus.COMPLETED,
DocumentSegmentSummary.status == SummaryStatus.ERROR,
),
- DatasetDocument.enabled == True, # Document must be enabled
- DatasetDocument.archived == False, # Document must not be archived
+ DatasetDocument.enabled.is_(True), # Document must be enabled
+ DatasetDocument.archived.is_(False), # Document must not be archived
DatasetDocument.doc_form != IndexStructureType.QA_INDEX, # Skip qa_model documents
)
.order_by(DocumentSegment.document_id.asc(), DocumentSegment.position.asc())
@@ -177,8 +177,8 @@ def regenerate_summary_index_task(
select(DatasetDocument).where(
DatasetDocument.dataset_id == dataset_id,
DatasetDocument.indexing_status == "completed",
- DatasetDocument.enabled == True,
- DatasetDocument.archived == False,
+ DatasetDocument.enabled.is_(True),
+ DatasetDocument.archived.is_(False),
)
).all()
@@ -214,7 +214,7 @@ def regenerate_summary_index_task(
DocumentSegment.document_id == dataset_document.id,
DocumentSegment.dataset_id == dataset_id,
DocumentSegment.status == "completed",
- DocumentSegment.enabled == True,
+ DocumentSegment.enabled.is_(True),
DocumentSegmentSummary.dataset_id == dataset_id,
)
.order_by(DocumentSegment.position.asc())
diff --git a/api/tests/test_containers_integration_tests/tasks/test_rag_pipeline_run_tasks.py b/api/tests/test_containers_integration_tests/tasks/test_rag_pipeline_run_tasks.py
index 5eea985fdcb..8311ce96736 100644
--- a/api/tests/test_containers_integration_tests/tasks/test_rag_pipeline_run_tasks.py
+++ b/api/tests/test_containers_integration_tests/tasks/test_rag_pipeline_run_tasks.py
@@ -251,7 +251,7 @@ class TestRagPipelineRunTasks:
assert call_kwargs["workflow_id"] == workflow.id
assert call_kwargs["user"].id == account.id
assert call_kwargs["invoke_from"] == InvokeFrom.PUBLISHED_PIPELINE
- assert call_kwargs["streaming"] == False
+ assert call_kwargs["streaming"] is False
assert isinstance(call_kwargs["application_generate_entity"], RagPipelineGenerateEntity)
def test_rag_pipeline_run_task_success(
@@ -296,7 +296,7 @@ class TestRagPipelineRunTasks:
assert call_kwargs["workflow_id"] == workflow.id
assert call_kwargs["user"].id == account.id
assert call_kwargs["invoke_from"] == InvokeFrom.PUBLISHED_PIPELINE
- assert call_kwargs["streaming"] == False
+ assert call_kwargs["streaming"] is False
assert isinstance(call_kwargs["application_generate_entity"], RagPipelineGenerateEntity)
def test_priority_rag_pipeline_run_task_with_waiting_tasks(
@@ -757,7 +757,7 @@ class TestRagPipelineRunTasks:
assert call_kwargs["workflow_id"] == workflow.id
assert call_kwargs["user"].id == account.id
assert call_kwargs["invoke_from"] == InvokeFrom.PUBLISHED_PIPELINE
- assert call_kwargs["streaming"] == False
+ assert call_kwargs["streaming"] is False
assert isinstance(call_kwargs["application_generate_entity"], RagPipelineGenerateEntity)
def test_run_single_rag_pipeline_task_entity_validation_error(
diff --git a/api/tests/unit_tests/core/mcp/client/test_sse.py b/api/tests/unit_tests/core/mcp/client/test_sse.py
index 6ec07261818..93e6e2ce2c8 100644
--- a/api/tests/unit_tests/core/mcp/client/test_sse.py
+++ b/api/tests/unit_tests/core/mcp/client/test_sse.py
@@ -177,15 +177,15 @@ def test_sse_transport_endpoint_validation():
# Valid endpoint (same origin)
valid_endpoint = "http://example.com/messages/session123"
- assert transport._validate_endpoint_url(valid_endpoint) == True
+ assert transport._validate_endpoint_url(valid_endpoint) is True
# Invalid endpoint (different origin)
invalid_endpoint = "http://malicious.com/messages/session123"
- assert transport._validate_endpoint_url(invalid_endpoint) == False
+ assert transport._validate_endpoint_url(invalid_endpoint) is False
# Invalid endpoint (different scheme)
invalid_scheme = "https://example.com/messages/session123"
- assert transport._validate_endpoint_url(invalid_scheme) == False
+ assert transport._validate_endpoint_url(invalid_scheme) is False
def test_sse_transport_message_parsing():
diff --git a/api/tests/unit_tests/core/variables/test_segment_type_validation.py b/api/tests/unit_tests/core/variables/test_segment_type_validation.py
index dcc928c2b05..e4050ce3b70 100644
--- a/api/tests/unit_tests/core/variables/test_segment_type_validation.py
+++ b/api/tests/unit_tests/core/variables/test_segment_type_validation.py
@@ -758,7 +758,7 @@ class TestSegmentTypeValidationIntegration:
result_first = segment_type.is_valid(valid_value, ArrayValidation.FIRST)
result_all = segment_type.is_valid(valid_value, ArrayValidation.ALL)
- assert result_none == result_first == result_all == True, (
+ assert result_none == result_first == result_all is True, (
f"{segment_type} should ignore array_validation parameter"
)
diff --git a/api/tests/unit_tests/core/workflow/generator/test_runner_missing.py b/api/tests/unit_tests/core/workflow/generator/test_runner_missing.py
index 8246fae1d1b..b39828044f0 100644
--- a/api/tests/unit_tests/core/workflow/generator/test_runner_missing.py
+++ b/api/tests/unit_tests/core/workflow/generator/test_runner_missing.py
@@ -28,39 +28,39 @@ def test_declares_variable():
# BuiltinNodeTypes is not imported directly, we need to mock or just use the generator method
# LLM node
- assert WorkflowGenerator._declares_variable({"data": {"type": "llm"}}, "text") == True
+ assert WorkflowGenerator._declares_variable({"data": {"type": "llm"}}, "text") is True
llm_so = {"data": {"type": "llm", "structured_output": {"schema": {"properties": {"json_var": {}}}}}}
- assert WorkflowGenerator._declares_variable(llm_so, "json_var") == True
- assert WorkflowGenerator._declares_variable(llm_so, "other_var") == False
+ assert WorkflowGenerator._declares_variable(llm_so, "json_var") is True
+ assert WorkflowGenerator._declares_variable(llm_so, "other_var") is False
# Code node
assert (
WorkflowGenerator._declares_variable({"data": {"type": "code", "outputs": {"code_var": "str"}}}, "code_var")
- == True
+ is True
)
# Knowledge retrieval
- assert WorkflowGenerator._declares_variable({"data": {"type": "knowledge-retrieval"}}, "result") == True
+ assert WorkflowGenerator._declares_variable({"data": {"type": "knowledge-retrieval"}}, "result") is True
# Parameter extractor
assert (
WorkflowGenerator._declares_variable(
{"data": {"type": "parameter-extractor", "parameters": [{"name": "param1"}]}}, "param1"
)
- == True
+ is True
)
# HTTP request
- assert WorkflowGenerator._declares_variable({"data": {"type": "http-request"}}, "body") == True
+ assert WorkflowGenerator._declares_variable({"data": {"type": "http-request"}}, "body") is True
# Template transform
- assert WorkflowGenerator._declares_variable({"data": {"type": "template-transform"}}, "output") == True
+ assert WorkflowGenerator._declares_variable({"data": {"type": "template-transform"}}, "output") is True
# Tool
- assert WorkflowGenerator._declares_variable({"data": {"type": "tool"}}, "anything") == True
+ assert WorkflowGenerator._declares_variable({"data": {"type": "tool"}}, "anything") is True
# Other node (default false)
- assert WorkflowGenerator._declares_variable({"data": {"type": "unknown"}}, "anything") == False
+ assert WorkflowGenerator._declares_variable({"data": {"type": "unknown"}}, "anything") is False
def test_collect_container_errors():
diff --git a/api/tests/unit_tests/models/test_workflow.py b/api/tests/unit_tests/models/test_workflow.py
index c8d213b75d0..a7f5cf5bf9f 100644
--- a/api/tests/unit_tests/models/test_workflow.py
+++ b/api/tests/unit_tests/models/test_workflow.py
@@ -298,7 +298,7 @@ class TestIsSystemVariableEditable:
for name, editable in cases:
assert editable == is_system_variable_editable(name)
- assert is_system_variable_editable("invalid_or_new_system_variable") == False
+ assert is_system_variable_editable("invalid_or_new_system_variable") is False
class TestWorkflowDraftVariableGetValue:
diff --git a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py
index ed4d78845d4..1269ed27c4a 100644
--- a/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py
+++ b/api/tests/unit_tests/services/workflow/test_workflow_draft_variable_service.py
@@ -63,8 +63,8 @@ class TestDraftVariableSaver:
node_execution_id="test_execution_id",
user=mock_user,
)
- assert saver._should_variable_be_visible("123_456", BuiltinNodeTypes.IF_ELSE, "output") == False
- assert saver._should_variable_be_visible("123", BuiltinNodeTypes.START, "output") == True
+ assert saver._should_variable_be_visible("123_456", BuiltinNodeTypes.IF_ELSE, "output") is False
+ assert saver._should_variable_be_visible("123", BuiltinNodeTypes.START, "output") is True
def test__normalize_variable_for_start_node(self, sqlite_session: Session):
@dataclasses.dataclass(frozen=True)
@@ -614,13 +614,13 @@ class TestWorkflowDraftVariableService:
def test_system_variable_editability_check(self):
"""Test the system variable editability function directly"""
# Test editable system variables
- assert is_system_variable_editable("files") == True
- assert is_system_variable_editable("query") == True
+ assert is_system_variable_editable("files") is True
+ assert is_system_variable_editable("query") is True
# Test non-editable system variables
- assert is_system_variable_editable("workflow_id") == False
- assert is_system_variable_editable("conversation_id") == False
- assert is_system_variable_editable("user_id") == False
+ assert is_system_variable_editable("workflow_id") is False
+ assert is_system_variable_editable("conversation_id") is False
+ assert is_system_variable_editable("user_id") is False
def test_workflow_draft_variable_factory_methods(self):
"""Test that factory methods create proper instances"""
@@ -632,7 +632,7 @@ class TestWorkflowDraftVariableService:
app_id=test_app_id, name="conv_var", value=test_value, description="Test conversation variable"
)
assert conv_var.get_variable_type() == DraftVariableType.CONVERSATION
- assert conv_var.editable == True
+ assert conv_var.editable is True
assert conv_var.node_execution_id is None
# Test system variable factory
@@ -640,7 +640,7 @@ class TestWorkflowDraftVariableService:
app_id=test_app_id, name="workflow_id", value=test_value, node_execution_id="exec-id", editable=False
)
assert sys_var.get_variable_type() == DraftVariableType.SYS
- assert sys_var.editable == False
+ assert sys_var.editable is False
assert sys_var.node_execution_id == "exec-id"
# Test node variable factory
@@ -654,8 +654,8 @@ class TestWorkflowDraftVariableService:
editable=True,
)
assert node_var.get_variable_type() == DraftVariableType.NODE
- assert node_var.visible == True
- assert node_var.editable == True
+ assert node_var.visible is True
+ assert node_var.editable is True
assert node_var.node_execution_id == "exec-id"