代码如下,问题是为什么在 select(cls) 后面 pycharm 不提示支持的关键词呢。或者有对应的插件能支持提示?

import typing
from sqlalchemy import Column, INT, String, func, event
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.sql import select
class MyBase(Base):
    # db.scalar(sql) 返回的是标量(原始数据) <models.department.Department object at 0x000002F2C2D22110>
    # db.execute(sql) 返回的是元组 (<models.department.Department object at 0x000002F2C2D22110>)
    # db.scalars(sql).all()  [<models...>, <models...>, <models...>]
    # db.execute(sql).fetchall()  [(<models...>,), (<models...>,), (<models...>,)]
    __abstract__ = True
    id = Column(INT, primary_key=True, autoincrement=True)
    create_time = Column(String(32), default=func.now())
    update_time = Column(String(32), default=func.now(), onupdate=func.now())
    # is_delete = Column(INT, default=0, comment="删除标志, 0 非删除 1 删除")

    @staticmethod
    def on_update(mapper, connection, target):
        target.update_time = now_time()

    @classmethod
    @user3n
    async def execute_by_session(cls,stmt,params,session:AsyncSession=None):
        """

        :param stmt: sqlalchemy Executable 对象
        :param params:  params 参数
        :param session:session db会话
        :return:
        """
        return await session.execute(stmt,params)

    @classmethod
    @user5n_router
    async def execute_by_local(cls,stmt,params):
        session = g.hr_db_session
        return await session.execute(stmt,params)

    @classmethod
    async def execute(cls,stmt,params:typing.Any = None):
        session = g.hr_db_session
        if session:
            return await session.execute(stmt,params)
        return cls.execute_by_session(stmt,params)


    @classmethod
    async def get_by_id(cls,id):
        conditions = [cls.id == id]
        if getattr(cls,"is_delete",None):
            conditions.append(cls.is_delete == 0)
        stmt = select(cls).where(*conditions)
        result = await cls.execute(stmt)
        data = result.scalar()
        return data


↙↙↙阅读原文可查看相关链接,并与作者交流