example add more type check (#24999)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Asuka Minato
2025-09-02 20:13:43 +09:00
committed by GitHub
parent 5aa8c9c8df
commit a418c43d32
2 changed files with 12 additions and 4 deletions

View File

@@ -1,7 +1,15 @@
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import DeclarativeBase, MappedAsDataclass
from models.engine import metadata
class Base(DeclarativeBase):
metadata = metadata
class TypeBase(MappedAsDataclass, DeclarativeBase):
"""
This is for adding type, after all finished, rename to Base.
"""
metadata = metadata

View File

@@ -14,7 +14,7 @@ from core.mcp.types import Tool
from core.tools.entities.common_entities import I18nObject
from core.tools.entities.tool_bundle import ApiToolBundle
from core.tools.entities.tool_entities import ApiProviderSchemaType, WorkflowToolParameterConfiguration
from models.base import Base
from models.base import Base, TypeBase
from .engine import db
from .model import Account, App, Tenant
@@ -160,7 +160,7 @@ class ApiToolProvider(Base):
return db.session.query(Tenant).where(Tenant.id == self.tenant_id).first()
class ToolLabelBinding(Base):
class ToolLabelBinding(TypeBase):
"""
The table stores the labels for tools.
"""
@@ -171,7 +171,7 @@ class ToolLabelBinding(Base):
sa.UniqueConstraint("tool_id", "label_name", name="unique_tool_label_bind"),
)
id: Mapped[str] = mapped_column(StringUUID, server_default=sa.text("uuid_generate_v4()"))
id: Mapped[str] = mapped_column(StringUUID, server_default=sa.text("uuid_generate_v4()"), init=False)
# tool id
tool_id: Mapped[str] = mapped_column(String(64), nullable=False)
# tool type