chore: avoid implicit optional in type annotations of method (#8727)
This commit is contained in:
parent
b360feb4c1
commit
240b66d737
37 changed files with 91 additions and 71 deletions
|
|
@ -321,7 +321,7 @@ class TenantService:
|
|||
return tenant
|
||||
|
||||
@staticmethod
|
||||
def switch_tenant(account: Account, tenant_id: int = None) -> None:
|
||||
def switch_tenant(account: Account, tenant_id: Optional[int] = None) -> None:
|
||||
"""Switch the current workspace for the account"""
|
||||
|
||||
# Ensure tenant_id is provided
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
from typing import Optional
|
||||
|
||||
|
||||
class BaseServiceError(Exception):
|
||||
def __init__(self, description: str = None):
|
||||
def __init__(self, description: Optional[str] = None):
|
||||
self.description = description
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
from flask_login import current_user
|
||||
from sqlalchemy import func
|
||||
|
|
@ -11,7 +12,7 @@ from models.model import App, Tag, TagBinding
|
|||
|
||||
class TagService:
|
||||
@staticmethod
|
||||
def get_tags(tag_type: str, current_tenant_id: str, keyword: str = None) -> list:
|
||||
def get_tags(tag_type: str, current_tenant_id: str, keyword: Optional[str] = None) -> list:
|
||||
query = (
|
||||
db.session.query(Tag.id, Tag.type, Tag.name, func.count(TagBinding.id).label("binding_count"))
|
||||
.outerjoin(TagBinding, Tag.id == TagBinding.tag_id)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from httpx import get
|
||||
|
||||
|
|
@ -79,7 +80,7 @@ class ApiToolManageService:
|
|||
raise ValueError(f"invalid schema: {str(e)}")
|
||||
|
||||
@staticmethod
|
||||
def convert_schema_to_tool_bundles(schema: str, extra_info: dict = None) -> list[ApiToolBundle]:
|
||||
def convert_schema_to_tool_bundles(schema: str, extra_info: Optional[dict] = None) -> list[ApiToolBundle]:
|
||||
"""
|
||||
convert schema to tool bundles
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class ToolTransformService:
|
|||
|
||||
@staticmethod
|
||||
def workflow_provider_to_user_provider(
|
||||
provider_controller: WorkflowToolProviderController, labels: list[str] = None
|
||||
provider_controller: WorkflowToolProviderController, labels: Optional[list[str]] = None
|
||||
):
|
||||
"""
|
||||
convert provider controller to user provider
|
||||
|
|
@ -174,7 +174,7 @@ class ToolTransformService:
|
|||
provider_controller: ApiToolProviderController,
|
||||
db_provider: ApiToolProvider,
|
||||
decrypt_credentials: bool = True,
|
||||
labels: list[str] = None,
|
||||
labels: Optional[list[str]] = None,
|
||||
) -> UserToolProvider:
|
||||
"""
|
||||
convert provider controller to user provider
|
||||
|
|
@ -223,9 +223,9 @@ class ToolTransformService:
|
|||
@staticmethod
|
||||
def tool_to_user_tool(
|
||||
tool: Union[ApiToolBundle, WorkflowTool, Tool],
|
||||
credentials: dict = None,
|
||||
tenant_id: str = None,
|
||||
labels: list[str] = None,
|
||||
credentials: Optional[dict] = None,
|
||||
tenant_id: Optional[str] = None,
|
||||
labels: Optional[list[str]] = None,
|
||||
) -> UserTool:
|
||||
"""
|
||||
convert tool to user tool
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import or_
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ class WorkflowToolManageService:
|
|||
description: str,
|
||||
parameters: list[dict],
|
||||
privacy_policy: str = "",
|
||||
labels: list[str] = None,
|
||||
labels: Optional[list[str]] = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Create a workflow tool.
|
||||
|
|
@ -106,7 +107,7 @@ class WorkflowToolManageService:
|
|||
description: str,
|
||||
parameters: list[dict],
|
||||
privacy_policy: str = "",
|
||||
labels: list[str] = None,
|
||||
labels: Optional[list[str]] = None,
|
||||
) -> dict:
|
||||
"""
|
||||
Update a workflow tool.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue