incomplete type declaration at `sqlite3.Connection.create_aggregate()`
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 5.1k
- 派生
- 2.1k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 82
描述
Bug report
Bug description:
The create_aggregate documentation does not specify a result type of the aggregation and even allows for multiple aggregating values per row (n_arg parameter).
However, the type declaration at dbapi2.pyi does not reflect that (comments added by me):
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
class _AggregateProtocol(Protocol):
def step(self, value: int, /) -> object: ... # <-- just one aggregating value of type int
def finalize(self) -> int: ... # <-- result has to be int
I think that this is not correct. At least, I have working code that aggregates multiple strings into a combined one.
Also, it is in stark contrast to other, way more generic, type declarations at the same place (comments added by me):
class _AnyParamWindowAggregateClass(Protocol):
def step(self, *args: Any) -> object: ... # <-- multiple aggregating values of any type allowed
def inverse(self, *args: Any) -> object: ...
def value(self) -> _SqliteData: ...
def finalize(self) -> _SqliteData: ... # <-- result can be many more types
_SqliteData: TypeAlias = str | ReadableBuffer | int | float | None
CPython versions tested on:
3.12
Operating systems tested on:
Windows
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 sqlite3 dbapi2.pyi 存根开始,将 create_aggregate 与文档中记载的 sqlite3.Connection.create_aggregate 行为进行比较。检查同一文件中的 _AnyParamWindowAggregateClass 和 _SqliteData,然后确定适用于多个输入值和非整数聚合结果的兼容声明;当存根能够准确接受文档中记载的用例时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100