python / python/typeshed

enum auto must not be derived from IntFlag

未关闭 适合新手
#8,286 4 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

When using auto enumeration within an class Example(enum.Enum): X = auto(), the invokation of auto() is actually constructing an instance of enum.auto, which just has a default constructor without any extra arguments.

However, when deriving class auto(IntFlag) in enum.pyi the stub actually has a constructor argument of type int, the value for the IntFlag.

This contradicts the definition in the original enum.py implementation.
As a matter of fact this leads to confusing type hints, e.g. enum class auto(IntFlag).

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先,将 enum.pyiauto 的定义与 issue 中提到的原始 enum.py 实现进行比较。检查两个文件中显示的构造函数和继承关系,然后更新 stub,使其定义与实现一致,并且不再生成令人困惑的类型提示 enum.auto(IntFlag)

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

评估

技术栈
python
领域
devtools
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
65/100

把新 issue 发到你的邮箱

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