Browse Source

chore(lint): sort __all__ definitions (#11243)

Bowen Liang 4 tháng trước cách đây
mục cha
commit
e79eac688a

+ 3 - 0
api/.ruff.toml

@@ -20,6 +20,8 @@ select = [
     "PLC0208", # iteration-over-set
     "PLC2801", # unnecessary-dunder-call
     "PLC0414", # useless-import-alias
+    "PLE0604", # invalid-all-object
+    "PLE0605", # invalid-all-format
     "PLR0402", # manual-from-import
     "PLR1711", # useless-return
     "PLR1714", # repeated-equality-comparison
@@ -28,6 +30,7 @@ select = [
     "RUF100", # unused-noqa
     "RUF101", # redirected-noqa
     "RUF200", # invalid-pyproject-toml
+    "RUF022", # unsorted-dunder-all
     "S506", # unsafe-yaml-load
     "SIM", # flake8-simplify rules
     "TRY400", # error-instead-of-exception

+ 6 - 6
api/core/file/__init__.py

@@ -7,13 +7,13 @@ from .models import (
 )
 
 __all__ = [
+    "FILE_MODEL_IDENTITY",
+    "ArrayFileAttribute",
+    "File",
+    "FileAttribute",
+    "FileBelongsTo",
+    "FileTransferMethod",
     "FileType",
     "FileUploadConfig",
-    "FileTransferMethod",
-    "FileBelongsTo",
-    "File",
     "ImageConfig",
-    "FileAttribute",
-    "ArrayFileAttribute",
-    "FILE_MODEL_IDENTITY",
 ]

+ 12 - 12
api/core/model_runtime/entities/__init__.py

@@ -18,25 +18,25 @@ from .message_entities import (
 from .model_entities import ModelPropertyKey
 
 __all__ = [
+    "AssistantPromptMessage",
+    "AudioPromptMessageContent",
+    "DocumentPromptMessageContent",
     "ImagePromptMessageContent",
-    "VideoPromptMessageContent",
-    "PromptMessage",
-    "PromptMessageRole",
+    "LLMResult",
+    "LLMResultChunk",
+    "LLMResultChunkDelta",
     "LLMUsage",
     "ModelPropertyKey",
-    "AssistantPromptMessage",
+    "PromptMessage",
     "PromptMessage",
     "PromptMessageContent",
+    "PromptMessageContentType",
     "PromptMessageRole",
+    "PromptMessageRole",
+    "PromptMessageTool",
     "SystemPromptMessage",
     "TextPromptMessageContent",
-    "UserPromptMessage",
-    "PromptMessageTool",
     "ToolPromptMessage",
-    "PromptMessageContentType",
-    "LLMResult",
-    "LLMResultChunk",
-    "LLMResultChunkDelta",
-    "AudioPromptMessageContent",
-    "DocumentPromptMessageContent",
+    "UserPromptMessage",
+    "VideoPromptMessageContent",
 ]

+ 1 - 1
api/core/model_runtime/model_providers/volcengine_maas/legacy/volc_sdk/__init__.py

@@ -1,4 +1,4 @@
 from .common import ChatRole
 from .maas import MaasError, MaasService
 
-__all__ = ["MaasService", "ChatRole", "MaasError"]
+__all__ = ["ChatRole", "MaasError", "MaasService"]

+ 21 - 21
api/core/variables/__init__.py

@@ -32,32 +32,32 @@ from .variables import (
 )
 
 __all__ = [
-    "IntegerVariable",
-    "FloatVariable",
-    "ObjectVariable",
-    "SecretVariable",
-    "StringVariable",
-    "ArrayAnyVariable",
-    "Variable",
-    "SegmentType",
-    "SegmentGroup",
-    "Segment",
-    "NoneSegment",
-    "NoneVariable",
-    "IntegerSegment",
-    "FloatSegment",
-    "ObjectSegment",
     "ArrayAnySegment",
-    "StringSegment",
-    "ArrayStringVariable",
-    "ArrayNumberVariable",
-    "ArrayObjectVariable",
-    "ArraySegment",
+    "ArrayAnyVariable",
     "ArrayFileSegment",
+    "ArrayFileVariable",
     "ArrayNumberSegment",
+    "ArrayNumberVariable",
     "ArrayObjectSegment",
+    "ArrayObjectVariable",
+    "ArraySegment",
     "ArrayStringSegment",
+    "ArrayStringVariable",
     "FileSegment",
     "FileVariable",
-    "ArrayFileVariable",
+    "FloatSegment",
+    "FloatVariable",
+    "IntegerSegment",
+    "IntegerVariable",
+    "NoneSegment",
+    "NoneVariable",
+    "ObjectSegment",
+    "ObjectVariable",
+    "SecretVariable",
+    "Segment",
+    "SegmentGroup",
+    "SegmentType",
+    "StringSegment",
+    "StringVariable",
+    "Variable",
 ]

+ 1 - 1
api/core/workflow/callbacks/__init__.py

@@ -2,6 +2,6 @@ from .base_workflow_callback import WorkflowCallback
 from .workflow_logging_callback import WorkflowLoggingCallback
 
 __all__ = [
-    "WorkflowLoggingCallback",
     "WorkflowCallback",
+    "WorkflowLoggingCallback",
 ]

+ 1 - 1
api/core/workflow/nodes/answer/__init__.py

@@ -1,4 +1,4 @@
 from .answer_node import AnswerNode
 from .entities import AnswerStreamGenerateRoute
 
-__all__ = ["AnswerStreamGenerateRoute", "AnswerNode"]
+__all__ = ["AnswerNode", "AnswerStreamGenerateRoute"]

+ 1 - 1
api/core/workflow/nodes/base/__init__.py

@@ -1,4 +1,4 @@
 from .entities import BaseIterationNodeData, BaseIterationState, BaseNodeData
 from .node import BaseNode
 
-__all__ = ["BaseNode", "BaseNodeData", "BaseIterationNodeData", "BaseIterationState"]
+__all__ = ["BaseIterationNodeData", "BaseIterationState", "BaseNode", "BaseNodeData"]

+ 1 - 1
api/core/workflow/nodes/end/__init__.py

@@ -1,4 +1,4 @@
 from .end_node import EndNode
 from .entities import EndStreamParam
 
-__all__ = ["EndStreamParam", "EndNode"]
+__all__ = ["EndNode", "EndStreamParam"]

+ 2 - 2
api/core/workflow/nodes/event/__init__.py

@@ -2,9 +2,9 @@ from .event import ModelInvokeCompletedEvent, RunCompletedEvent, RunRetrieverRes
 from .types import NodeEvent
 
 __all__ = [
+    "ModelInvokeCompletedEvent",
+    "NodeEvent",
     "RunCompletedEvent",
     "RunRetrieverResourceEvent",
     "RunStreamChunkEvent",
-    "NodeEvent",
-    "ModelInvokeCompletedEvent",
 ]

+ 1 - 1
api/core/workflow/nodes/http_request/__init__.py

@@ -1,4 +1,4 @@
 from .entities import BodyData, HttpRequestNodeAuthorization, HttpRequestNodeBody, HttpRequestNodeData
 from .node import HttpRequestNode
 
-__all__ = ["HttpRequestNodeData", "HttpRequestNodeAuthorization", "HttpRequestNodeBody", "BodyData", "HttpRequestNode"]
+__all__ = ["BodyData", "HttpRequestNode", "HttpRequestNodeAuthorization", "HttpRequestNodeBody", "HttpRequestNodeData"]

+ 1 - 1
api/core/workflow/nodes/question_classifier/__init__.py

@@ -1,4 +1,4 @@
 from .entities import QuestionClassifierNodeData
 from .question_classifier_node import QuestionClassifierNode
 
-__all__ = ["QuestionClassifierNodeData", "QuestionClassifierNode"]
+__all__ = ["QuestionClassifierNode", "QuestionClassifierNodeData"]

+ 1 - 1
api/core/workflow/nodes/variable_assigner/__init__.py

@@ -2,7 +2,7 @@ from .node import VariableAssignerNode
 from .node_data import VariableAssignerData, WriteMode
 
 __all__ = [
-    "VariableAssignerNode",
     "VariableAssignerData",
+    "VariableAssignerNode",
     "WriteMode",
 ]

+ 17 - 17
api/models/__init__.py

@@ -24,30 +24,30 @@ from .workflow import (
 )
 
 __all__ = [
+    "Account",
+    "AccountIntegrate",
+    "ApiToken",
+    "App",
+    "AppMode",
+    "Conversation",
     "ConversationVariable",
-    "Document",
+    "DataSourceOauthBinding",
     "Dataset",
     "DatasetProcessRule",
+    "Document",
     "DocumentSegment",
-    "DataSourceOauthBinding",
-    "AppMode",
-    "Workflow",
-    "App",
-    "Message",
     "EndUser",
-    "MessageFile",
-    "UploadFile",
-    "Account",
-    "WorkflowAppLog",
-    "WorkflowRun",
-    "Site",
     "InstalledApp",
-    "RecommendedApp",
-    "ApiToken",
-    "AccountIntegrate",
     "InvitationCode",
-    "Tenant",
-    "Conversation",
+    "Message",
     "MessageAnnotation",
+    "MessageFile",
+    "RecommendedApp",
+    "Site",
+    "Tenant",
     "ToolFile",
+    "UploadFile",
+    "Workflow",
+    "WorkflowAppLog",
+    "WorkflowRun",
 ]

+ 8 - 8
api/services/errors/__init__.py

@@ -14,16 +14,16 @@ from . import (
 )
 
 __all__ = [
-    "base",
-    "conversation",
-    "message",
-    "index",
-    "app_model_config",
     "account",
-    "document",
-    "dataset",
     "app",
-    "completion",
+    "app_model_config",
     "audio",
+    "base",
+    "completion",
+    "conversation",
+    "dataset",
+    "document",
     "file",
+    "index",
+    "message",
 ]