python / python/typeshed

Optional dependencies

未关闭
#15,549 2 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

See #15548 for an example of this problem.

Currently, we don't support optional dependencies in typeshed. Say a third-party package has some additional functionality if another third-party package is installed. For example, Authlib has a module authlib.integrations.requests_client that works only if requests is also installed. This leads to the awkward situation that our stubs for that module have many comments of the form "Inherits from requests.Session".

I suggest that we should add support for optional dependencies. Here's an idea:

  • Add a field optional-requires to METADATA.toml. stub_uploader checks that this has the same limitations as requires.
  • In tests optional-requires is treated the same way that requires is, i.e. the packages mentioned there are installed.
  • stub_uploader adds this new field to project.optional-dependencies in pyproject.toml.

(Sidenote: Maybe we should rename requires to dependencies to match pyproject.toml.)

Linked PR:

  • typeshed-internal/stub_uploader#203
  • typeshed-internal/stub_uploader#208
  • #15706

贡献指南

打开贡献指南

从这里开始

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

调研方向

先阅读 METADATA.toml 的处理逻辑和 stub_uploader 的验证,然后检查从 requires 安装软件包的测试。定义 optional-requires 元数据的行为,并确认测试所需的相关软件包已安装,同时检查所引用的 stub_uploader PR 和 #15706,了解已有的决定。

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

评估

技术栈
python
领域
build-system, tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

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