mirror of
https://github.com/langgenius/dify.git
synced 2026-02-13 07:01:23 -05:00
feat: mypy for all type check (#10921)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
from app_fixture import app, mock_user
|
||||
from app_fixture import mock_user # type: ignore
|
||||
|
||||
|
||||
def test_post_requires_login(app):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import google.generativeai.types.generation_types as generation_config_types
|
||||
import google.generativeai.types.generation_types as generation_config_types # type: ignore
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from google.ai import generativelanguage as glm
|
||||
@@ -45,7 +45,7 @@ class MockGoogleClass:
|
||||
return GenerateContentResponse(done=True, iterator=None, result=glm.GenerateContentResponse({}), chunks=[])
|
||||
|
||||
@staticmethod
|
||||
def generate_content_stream() -> Generator[GenerateContentResponse, None, None]:
|
||||
def generate_content_stream() -> MockGoogleResponseClass:
|
||||
return MockGoogleResponseClass()
|
||||
|
||||
def generate_content(
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from huggingface_hub import InferenceClient
|
||||
from huggingface_hub import InferenceClient # type: ignore
|
||||
|
||||
from tests.integration_tests.model_runtime.__mock.huggingface_chat import MockHuggingfaceChatClass
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ from collections.abc import Generator
|
||||
from typing import Any, Literal, Optional, Union
|
||||
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from huggingface_hub import InferenceClient
|
||||
from huggingface_hub.inference._text_generation import (
|
||||
from huggingface_hub import InferenceClient # type: ignore
|
||||
from huggingface_hub.inference._text_generation import ( # type: ignore
|
||||
Details,
|
||||
StreamDetails,
|
||||
TextGenerationResponse,
|
||||
TextGenerationStreamResponse,
|
||||
Token,
|
||||
)
|
||||
from huggingface_hub.utils import BadRequestError
|
||||
from huggingface_hub.utils import BadRequestError # type: ignore
|
||||
|
||||
|
||||
class MockHuggingfaceChatClass:
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
# import monkeypatch
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from nomic import embed
|
||||
from nomic import embed # type: ignore
|
||||
|
||||
|
||||
def create_embedding(texts: list[str], model: str, **kwargs: Any) -> dict:
|
||||
|
||||
@@ -6,14 +6,14 @@ import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from requests import Response
|
||||
from requests.sessions import Session
|
||||
from xinference_client.client.restful.restful_client import (
|
||||
from xinference_client.client.restful.restful_client import ( # type: ignore
|
||||
Client,
|
||||
RESTfulChatModelHandle,
|
||||
RESTfulEmbeddingModelHandle,
|
||||
RESTfulGenerateModelHandle,
|
||||
RESTfulRerankModelHandle,
|
||||
)
|
||||
from xinference_client.types import Embedding, EmbeddingData, EmbeddingUsage
|
||||
from xinference_client.types import Embedding, EmbeddingData, EmbeddingUsage # type: ignore
|
||||
|
||||
|
||||
class MockXinferenceClass:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
import dashscope
|
||||
import dashscope # type: ignore
|
||||
import pytest
|
||||
|
||||
from core.model_runtime.entities.rerank_entities import RerankResult
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from flask import Flask, request
|
||||
from flask_restful import Api, Resource
|
||||
from flask_restful import Api, Resource # type: ignore
|
||||
|
||||
app = Flask(__name__)
|
||||
api = Api(app)
|
||||
|
||||
@@ -4,11 +4,11 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from pymochow import MochowClient
|
||||
from pymochow.model.database import Database
|
||||
from pymochow.model.enum import IndexState, IndexType, MetricType, ReadConsistency, TableState
|
||||
from pymochow.model.schema import HNSWParams, VectorIndex
|
||||
from pymochow.model.table import Table
|
||||
from pymochow import MochowClient # type: ignore
|
||||
from pymochow.model.database import Database # type: ignore
|
||||
from pymochow.model.enum import IndexState, IndexType, MetricType, ReadConsistency, TableState # type: ignore
|
||||
from pymochow.model.schema import HNSWParams, VectorIndex # type: ignore
|
||||
from pymochow.model.table import Table # type: ignore
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ from typing import Optional
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from requests.adapters import HTTPAdapter
|
||||
from tcvectordb import VectorDBClient
|
||||
from tcvectordb.model.database import Collection, Database
|
||||
from tcvectordb.model.document import Document, Filter
|
||||
from tcvectordb.model.enum import ReadConsistency
|
||||
from tcvectordb.model.index import Index
|
||||
from xinference_client.types import Embedding
|
||||
from tcvectordb import VectorDBClient # type: ignore
|
||||
from tcvectordb.model.database import Collection, Database # type: ignore
|
||||
from tcvectordb.model.document import Document, Filter # type: ignore
|
||||
from tcvectordb.model.enum import ReadConsistency # type: ignore
|
||||
from tcvectordb.model.index import Index # type: ignore
|
||||
from xinference_client.types import Embedding # type: ignore
|
||||
|
||||
|
||||
class MockTcvectordbClass:
|
||||
|
||||
@@ -4,7 +4,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from volcengine.viking_db import (
|
||||
from volcengine.viking_db import ( # type: ignore
|
||||
Collection,
|
||||
Data,
|
||||
DistanceType,
|
||||
|
||||
Reference in New Issue
Block a user