chore: apply ruff rules on tests and app.py (#3605)

This commit is contained in:
Bowen Liang
2024-04-18 20:24:05 +08:00
committed by GitHub
parent d5448e07ab
commit d9b821cecc
92 changed files with 383 additions and 181 deletions

View File

@@ -1,4 +1,4 @@
from typing import Generator, List
from collections.abc import Generator
import google.generativeai.types.content_types as content_types
import google.generativeai.types.generation_types as generation_config_types
@@ -6,15 +6,15 @@ import google.generativeai.types.safety_types as safety_types
import pytest
from _pytest.monkeypatch import MonkeyPatch
from google.ai import generativelanguage as glm
from google.ai.generativelanguage_v1beta.types import content as gag_content
from google.generativeai import GenerativeModel
from google.generativeai.client import _ClientManager, configure
from google.generativeai.types import GenerateContentResponse
from google.generativeai.types.generation_types import BaseGenerateContentResponse
from google.ai.generativelanguage_v1beta.types import content as gag_content
current_api_key = ''
class MockGoogleResponseClass(object):
class MockGoogleResponseClass:
_done = False
def __iter__(self):
@@ -41,7 +41,7 @@ class MockGoogleResponseClass(object):
chunks=[]
)
class MockGoogleResponseCandidateClass(object):
class MockGoogleResponseCandidateClass:
finish_reason = 'stop'
@property
@@ -52,7 +52,7 @@ class MockGoogleResponseCandidateClass(object):
]
)
class MockGoogleClass(object):
class MockGoogleClass:
@staticmethod
def generate_content_sync() -> GenerateContentResponse:
return GenerateContentResponse(
@@ -91,7 +91,7 @@ class MockGoogleClass(object):
return 'it\'s google!'
@property
def generative_response_candidates(self) -> List[MockGoogleResponseCandidateClass]:
def generative_response_candidates(self) -> list[MockGoogleResponseCandidateClass]:
return [MockGoogleResponseCandidateClass()]
def make_client(self: _ClientManager, name: str):