chore: apply ruff's pyupgrade linter rules to modernize Python code with targeted version (#2419)

This commit is contained in:
Bowen Liang
2024-02-09 15:21:33 +08:00
committed by GitHub
parent 589099a005
commit 063191889d
246 changed files with 912 additions and 937 deletions

View File

@@ -1,5 +1,5 @@
from enum import Enum
from typing import Any, Dict, List, Optional, Union, cast
from typing import Any, Optional, Union, cast
from pydantic import BaseModel, Field
@@ -82,7 +82,7 @@ class ToolInvokeMessage(BaseModel):
plain text, image url or link url
"""
message: Union[str, bytes] = None
meta: Dict[str, Any] = None
meta: dict[str, Any] = None
save_as: str = ''
class ToolInvokeMessageBinary(BaseModel):
@@ -116,12 +116,12 @@ class ToolParameter(BaseModel):
default: Optional[str] = None
min: Optional[Union[float, int]] = None
max: Optional[Union[float, int]] = None
options: Optional[List[ToolParameterOption]] = None
options: Optional[list[ToolParameterOption]] = None
@classmethod
def get_simple_instance(cls,
name: str, llm_description: str, type: ToolParameterType,
required: bool, options: Optional[List[str]] = None) -> 'ToolParameter':
required: bool, options: Optional[list[str]] = None) -> 'ToolParameter':
"""
get a simple tool parameter
@@ -192,7 +192,7 @@ class ToolProviderCredentials(BaseModel):
type: CredentialsType = Field(..., description="The type of the credentials")
required: bool = False
default: Optional[str] = None
options: Optional[List[ToolCredentialsOption]] = None
options: Optional[list[ToolCredentialsOption]] = None
label: Optional[I18nObject] = None
help: Optional[I18nObject] = None
url: Optional[str] = None
@@ -232,7 +232,7 @@ class ToolRuntimeVariablePool(BaseModel):
user_id: str = Field(..., description="The user id")
tenant_id: str = Field(..., description="The tenant id of assistant")
pool: List[ToolRuntimeVariable] = Field(..., description="The pool of variables")
pool: list[ToolRuntimeVariable] = Field(..., description="The pool of variables")
def __init__(self, **data: Any):
pool = data.get('pool', [])