python / python/typeshed

Flask-SQLAlchemy-Lite support for flask-migrate

未关闭
#12,121 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

stubs: improvement
主要语言
Python
星标
5.1k
派生
2.1k
平均合并
1 天 19 小时
30 天内合并 PR
82

描述

Flask-SQLAlchemy-Lite was just released which is intended to be a replacement for Flask-SQLAlchemy.
https://flask-sqlalchemy-lite.readthedocs.io/en/stable/

With that there is then a type conflict with flask_migrate:
https://github.com/python/typeshed/blob/main/stubs/Flask-Migrate/flask_migrate/__init__.pyi#L52

It expects flask_sqlalchemy.extension.SQLAlchemy, but flask_sqlalchemy_lite._extension.SQLAlchemy is now a compatible alternative

I'm pretty new to python so I'm not sure what the best approach to allow the flask_migrate typings to allow both.

Would it work to:

# ...
from flask_sqlalchemy import SQLAlchemy
from flask_sqlalchemy_lite import SQLAlchemy as SQLAlchemyLite
# ...
class Migrate:
    configure_callbacks: list[_ConfigureCallback]
    db: SQLAlchemy | SQLAlchemyLite | None
    # ...

Or is there a better approach?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 stubs/Flask-Migrate/flask_migrate/init.pyi 中的 Flask-Migrate stub 开始,重点查看第 52 行附近的 SQLAlchemy 类型,并审阅链接的 Flask-SQLAlchemy-Lite 文档。确定一种类型标注方案,使其能够接受两种 SQLAlchemy 实现,同时不引入导入或兼容性冲突;当该 stub 能够准确支持任一集成时即完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
flask, python, sqlalchemy
领域
backend, tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。