Support `enum.global_enum`
未关闭
还没有人认领这个 Issue。
feature
- 主要语言
- Python
- 星标
- 20.6k
- 派生
- 3.3k
- PR 合并指标
- PR 指标待抓取
描述
Feature
Mypy should support module-level constants defined by enum.global_enum.
Pitch
enum.global_enum adds an enum’s members to the global namespace. Mypy reports errors for any use of global constants defined that way. It would make enum_global much more usable if mypy recognized them as defined.
Example file:
import enum
@enum.global_enum
class Example(enum.Enum):
X = enum.auto()
print(X)
Current behavior:
$ python3.11 global_enum.py
X
$ mypy global_enum.py
global_enum.py:7: error: Name "X" is not defined [name-defined]
Found 1 error in 1 file (checked 1 source file)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 Python 和 mypy 运行提供的 global_enum.py 示例,然后跟踪 mypy 如何处理 enum 装饰器和模块级名称绑定。为 enum.global_enum 导出的名称添加支持,并验证该示例不再报告 name-defined 错误,同时为此情况添加回归测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100