chore: removing unused imports in tests (#9049)
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions

This commit is contained in:
Bowen Liang 2024-10-08 11:13:11 +08:00 committed by GitHub
parent a8b4d1ac2a
commit 7c0b159a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 21 additions and 52 deletions

View File

@ -26,7 +26,7 @@ from commands import register_commands
from configs import dify_config
# DO NOT REMOVE BELOW
from events import event_handlers
from events import event_handlers # noqa: F401
from extensions import (
ext_celery,
ext_code_based_extension,
@ -45,7 +45,7 @@ from extensions.ext_login import login_manager
from libs.passport import PassportService
# TODO: Find a way to avoid importing models here
from models import account, dataset, model, source, task, tool, tools, web
from models import account, dataset, model, source, task, tool, tools, web # noqa: F401
from services.account_service import AccountService
# DO NOT REMOVE ABOVE
@ -181,10 +181,10 @@ def load_user_from_request(request_from_flask_login):
decoded = PassportService().verify(auth_token)
user_id = decoded.get("user_id")
account = AccountService.load_logged_in_account(account_id=user_id, token=auth_token)
if account:
contexts.tenant_id.set(account.current_tenant_id)
return account
logged_in_account = AccountService.load_logged_in_account(account_id=user_id, token=auth_token)
if logged_in_account:
contexts.tenant_id.set(logged_in_account.current_tenant_id)
return logged_in_account
@login_manager.unauthorized_handler

2
api/poetry.lock generated
View File

@ -10595,4 +10595,4 @@ cffi = ["cffi (>=1.11)"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.10,<3.13"
content-hash = "dbcbcd7addb7c35c67f074fce00f6e25ec1e225498e5b9de3ef2fcd6af749bf6"
content-hash = "d29d0c4ce384ef94fe65f0a2a145898bd1a117d4fd59c217d15bbb8993f4ce4e"

View File

@ -74,8 +74,6 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"app.py" = [
"F401", # unused-import
"F811", # redefined-while-unused
]
"__init__.py" = [
"F401", # unused-import
@ -88,10 +86,15 @@ ignore = [
"N803", # invalid-argument-name
]
"tests/*" = [
"F401", # unused-import
"F811", # redefined-while-unused
]
[tool.ruff.lint.pyflakes]
allowed-unused-imports=[
"_pytest.monkeypatch",
"tests.integration_tests",
]
[tool.ruff.format]
exclude = [
]
@ -260,4 +263,4 @@ optional = true
[tool.poetry.group.lint.dependencies]
dotenv-linter = "~0.5.0"
ruff = "~0.6.8"
ruff = "~0.6.9"

View File

@ -5,7 +5,7 @@ from typing import Any, Literal, Union
import anthropic
import pytest
from _pytest.monkeypatch import MonkeyPatch
from anthropic import Anthropic, Stream
from anthropic import Stream
from anthropic.resources import Messages
from anthropic.types import (
ContentBlock,

View File

@ -1,6 +1,6 @@
import os
from collections.abc import Callable
from typing import Any, Literal, Union
from typing import Any, Literal
import pytest

View File

@ -1,6 +1,6 @@
import re
from collections.abc import Generator
from json import dumps, loads
from json import dumps
from time import time
# import monkeypatch
@ -11,11 +11,9 @@ from openai._types import NOT_GIVEN, NotGiven
from openai.resources.chat.completions import Completions
from openai.types import Completion as CompletionMessage
from openai.types.chat import (
ChatCompletion,
ChatCompletionChunk,
ChatCompletionMessageParam,
ChatCompletionMessageToolCall,
ChatCompletionToolChoiceOptionParam,
ChatCompletionToolParam,
completion_create_params,
)

View File

@ -1,7 +1,6 @@
import re
from typing import Any, Literal, Union
from openai import OpenAI
from openai._types import NOT_GIVEN, NotGiven
from openai.resources.embeddings import Embeddings
from openai.types.create_embedding_response import CreateEmbeddingResponse, Usage

View File

@ -1,6 +1,5 @@
from time import time
from openai.resources.models import Models
from openai.types.model import Model

View File

@ -5,7 +5,6 @@ from typing import Union
import pytest
from _pytest.monkeypatch import MonkeyPatch
from requests import Response
from requests.exceptions import ConnectionError
from requests.sessions import Session
from xinference_client.client.restful.restful_client import (
Client,

View File

@ -6,10 +6,7 @@ import pytest
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
ImagePromptMessageContent,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.errors.validate import CredentialsValidateFailedError

View File

@ -8,7 +8,6 @@ from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.entities.model_entities import AIModelEntity

View File

@ -2,8 +2,7 @@ import os
import pytest
from core.model_runtime.entities.rerank_entities import RerankDocument, RerankResult
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult
from core.model_runtime.entities.rerank_entities import RerankResult
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.huggingface_tei.rerank.rerank import (
HuggingfaceTeiRerankModel,

View File

@ -8,10 +8,8 @@ from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.entities.model_entities import ParameterRule
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.localai.llm.llm import LocalAILanguageModel

View File

@ -4,7 +4,6 @@ import pytest
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.nomic.nomic import NomicAtlasProvider
from core.model_runtime.model_providers.nomic.text_embedding.text_embedding import NomicTextEmbeddingModel
from tests.integration_tests.model_runtime.__mock.nomic_embeddings import setup_nomic_mock

View File

@ -6,7 +6,6 @@ import pytest
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
UserPromptMessage,
)

View File

@ -8,7 +8,6 @@ from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.errors.validate import CredentialsValidateFailedError

View File

@ -14,7 +14,6 @@ from core.model_runtime.entities.message_entities import (
)
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
from core.model_runtime.model_providers.openai.llm.llm import OpenAILargeLanguageModel
"""FOR MOCK FIXTURES, DO NOT REMOVE"""

View File

@ -6,7 +6,6 @@ import pytest
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
UserPromptMessage,
)

View File

@ -1,5 +1,3 @@
import os
import pytest
from core.model_runtime.errors.validate import CredentialsValidateFailedError

View File

@ -1,5 +1,3 @@
import os
import pytest
from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult

View File

@ -6,13 +6,11 @@ import pytest
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
ImagePromptMessageContent,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
from core.model_runtime.entities.model_entities import AIModelEntity
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.stepfun.llm.llm import StepfunLargeLanguageModel

View File

@ -6,7 +6,6 @@ import pytest
from core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDelta
from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
UserPromptMessage,
)

View File

@ -10,9 +10,8 @@ from core.model_runtime.entities.message_entities import (
SystemPromptMessage,
UserPromptMessage,
)
from core.model_runtime.entities.model_entities import AIModelEntity, ModelType
from core.model_runtime.entities.model_entities import AIModelEntity
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel
from core.model_runtime.model_providers.upstage.llm.llm import UpstageLargeLanguageModel
"""FOR MOCK FIXTURES, DO NOT REMOVE"""

View File

@ -8,10 +8,8 @@ from core.model_runtime.entities.message_entities import (
AssistantPromptMessage,
PromptMessageTool,
SystemPromptMessage,
TextPromptMessageContent,
UserPromptMessage,
)
from core.model_runtime.entities.model_entities import AIModelEntity
from core.model_runtime.errors.validate import CredentialsValidateFailedError
from core.model_runtime.model_providers.xinference.llm.llm import XinferenceAILargeLanguageModel

View File

@ -1,5 +1,4 @@
from core.rag.datasource.vdb.pgvector.pgvector import PGVector, PGVectorConfig
from core.rag.models.document import Document
from tests.integration_tests.vdb.test_vector_store import (
AbstractVectorTest,
get_example_text,

View File

@ -1,4 +1,3 @@
import random
import uuid
from unittest.mock import MagicMock

View File

@ -1,5 +1,5 @@
import os
from typing import Literal, Optional
from typing import Literal
import pytest
from _pytest.monkeypatch import MonkeyPatch

View File

@ -1,4 +1,3 @@
import json
import os
import time
import uuid

View File

@ -2,7 +2,6 @@ import pytest
from pydantic import ValidationError
from core.app.segments import (
ArrayAnyVariable,
FloatVariable,
IntegerVariable,
ObjectVariable,

View File

@ -1,9 +1,6 @@
import os
from unittest import mock
from core.rag.extractor.firecrawl.firecrawl_app import FirecrawlApp
from core.rag.extractor.firecrawl.firecrawl_web_extractor import FirecrawlWebExtractor
from core.rag.models.document import Document
from tests.unit_tests.core.rag.extractor.test_notion_extractor import _mock_response