Type hint mismatch for list API responses

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

维护者通常 1 天内回复

@AyeshaNasirWebDeveloper 已经在做这个了。

开始于 2026年8月19日。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
58/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
api

调研方向

先阅读 issue 中的 send_request 入口和 Ticker24hrResponse2.from_dict 示例,然后跟踪顶层列表响应是如何进行注解和解析的。完成的标准是:对于列表响应,声明的返回类型与运行时的 ApiResponse[list[T]] 行为一致,同时不改变其他响应形状的处理方式。

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

描述

Hi! I’m currently using the binance-sdk-derivatives-trading-usds-futures SDK while migrating from the deprecated version.

I noticed that the return type of the USD Futures API is always annotated as ApiResponse[T], but in cases where the response is a top-level list, the actual return type is ApiResponse[list[T]].

Is this intentional?

def send_request(...):
  ...
  
  if (is_list and not is_flat_list) or not response_model:
     data_function = lambda: parsed
  elif is_oneof or is_list:
     data_function = lambda: response_model.from_dict(parsed)
  else:
     data_function = lambda: response_model.model_validate(parsed)
    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[list[Self]]:
        """Create an instance of Ticker24hrResponse2 from a dict"""
        return [cls.model_validate(item) for item in obj]
主要语言
Python
星标
3k
派生
712
平均合并
1 天 13 小时
30 天内合并 PR
9

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

binance/binance-connector-python 的其他 Issue

查看 binance/binance-connector-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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