Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pre-commit-config and apply format. #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.1
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
24 changes: 12 additions & 12 deletions python/dify_plugin/core/plugin_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@
from werkzeug import Response

from dify_plugin.config.config import DifyPluginEnv
from dify_plugin.core.plugin_registration import PluginRegistration
from dify_plugin.core.runtime import Session
from dify_plugin.core.utils.http_parser import parse_raw_request
from dify_plugin.entities.tool import ToolRuntime
from dify_plugin.interfaces.endpoint import Endpoint
from dify_plugin.interfaces.model.ai_model import AIModel
from dify_plugin.interfaces.model.large_language_model import LargeLanguageModel
from dify_plugin.interfaces.model.moderation_model import ModerationModel
from dify_plugin.interfaces.model.rerank_model import RerankModel
from dify_plugin.interfaces.model.speech2text_model import Speech2TextModel
from dify_plugin.interfaces.model.text_embedding_model import TextEmbeddingModel
from dify_plugin.interfaces.model.tts_model import TTSModel
from dify_plugin.core.entities.plugin.request import (
EndpointInvokeRequest,
ModelGetAIModelSchemas,
Expand All @@ -35,6 +23,18 @@
ToolInvokeRequest,
ToolValidateCredentialsRequest,
)
from dify_plugin.core.plugin_registration import PluginRegistration
from dify_plugin.core.runtime import Session
from dify_plugin.core.utils.http_parser import parse_raw_request
from dify_plugin.entities.tool import ToolRuntime
from dify_plugin.interfaces.endpoint import Endpoint
from dify_plugin.interfaces.model.ai_model import AIModel
from dify_plugin.interfaces.model.large_language_model import LargeLanguageModel
from dify_plugin.interfaces.model.moderation_model import ModerationModel
from dify_plugin.interfaces.model.rerank_model import RerankModel
from dify_plugin.interfaces.model.speech2text_model import Speech2TextModel
from dify_plugin.interfaces.model.text_embedding_model import TextEmbeddingModel
from dify_plugin.interfaces.model.tts_model import TTSModel


class PluginExecutor:
Expand Down
1 change: 0 additions & 1 deletion python/dify_plugin/core/plugin_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from dify_plugin.interfaces.model.tts_model import TTSModel
from dify_plugin.interfaces.tool import Tool, ToolProvider


T = TypeVar("T")


Expand Down
1 change: 0 additions & 1 deletion python/dify_plugin/core/server/tcp/request_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from gevent.select import select

from dify_plugin.core.entities.message import InitializeMessage

from dify_plugin.core.entities.plugin.io import (
PluginInStream,
PluginInStreamEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SystemPromptMessage,
UserPromptMessage,
)

from .ai_model import AIModel

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
CredentialsValidateFailedError,
InvokeBadRequestError,
)
from dify_plugin.interfaces.model.speech2text_model import Speech2TextModel
from dify_plugin.interfaces.model.openai_compatible.common import _CommonOaiApiCompat
from dify_plugin.interfaces.model.speech2text_model import Speech2TextModel


class OAICompatSpeech2TextModel(_CommonOaiApiCompat, Speech2TextModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from dify_plugin.errors.model import (
CredentialsValidateFailedError,
)
from dify_plugin.interfaces.model.text_embedding_model import TextEmbeddingModel
from dify_plugin.interfaces.model.openai_compatible.common import _CommonOaiApiCompat
from dify_plugin.interfaces.model.text_embedding_model import TextEmbeddingModel


class OAICompatEmbeddingModel(_CommonOaiApiCompat, TextEmbeddingModel):
Expand Down
3 changes: 1 addition & 2 deletions python/dify_plugin/interfaces/tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
from collections.abc import Generator
from typing import Any, Optional

from dify_plugin.file.entities import FileType

from dify_plugin.core.runtime import Session
from dify_plugin.entities.tool import ToolInvokeMessage, ToolParameter, ToolRuntime
from dify_plugin.file.constants import DIFY_FILE_IDENTITY
from dify_plugin.file.entities import FileType
from dify_plugin.file.file import File


Expand Down
2 changes: 1 addition & 1 deletion python/examples/code_based_workflow/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dify_plugin import Plugin, DifyPluginEnv
from dify_plugin import DifyPluginEnv, Plugin

plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=30))

Expand Down
2 changes: 1 addition & 1 deletion python/examples/google/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dify_plugin import Plugin, DifyPluginEnv
from dify_plugin import DifyPluginEnv, Plugin

plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=30))

Expand Down
2 changes: 1 addition & 1 deletion python/examples/jina/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dify_plugin import Plugin, DifyPluginEnv
from dify_plugin import DifyPluginEnv, Plugin

plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=30))

Expand Down