Docstring says t.Tuple is supported, but typing.Tuple raises AttributeError
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 88/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 Env docstring(位于 envier/env.py 第 232-233 行)开始,其中 t.Tuple 与 list 和 set 并列列出。阅读 EnvVariable._cast(第 78-87 行)和 _check_type(第 28-32 行),确认裸的 typing.Tuple 别名没有 __args__。最简单的修复是把 docstring 改成 tuple;或者将 typing.Tuple/List/Set 规范化为它们的原始类型。运行现有的 collection 测试,如果进行规范化,再添加一个 typing.Tuple 用例。
由索引模型根据 Issue 内容生成。
描述
The Env docstring says t.Tuple is supported as a collection type, but declaring a variable with typing.Tuple raises AttributeError when the value is read. The builtin tuple works.
Environment: envier 0.6.1, Python 3.12
Reproduction
import json
import typing
from envier import Env
try:
class C(Env):
x = Env.var(typing.Tuple, "x")
print(json.dumps(C({"X": "a,b"}).x))
except Exception as e:
print(json.dumps(type(e).__name__))
Actual output
"AttributeError"
Expected output
["a", "b"]
From the Env class docstring:
There is also basic support for collections. An item of type
list,t.Tupleorsetwill be parsed using,as item separator.
Likely cause: EnvVariable._cast only handles _type in (list, tuple, set), so typing.Tuple falls through to _check_type, which reads _type.__args__; the bare typing.Tuple alias has no __args__:
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L28-L32
https://github.com/DataDog/envier/blob/a8ee033fd2581be09c0d61eb6b8343f12c8f08e9/envier/env.py#L78-L87
Since the same sentence lists the builtins list and set and the tests use builtin tuple, the simplest fix may be to change t.Tuple to tuple in the docstring; alternatively typing.Tuple (and typing.List/typing.Set) could be normalized to their origin types.
Found while testing the library with an automated exploration tool; the reproduction above was re-run on 0.6.1 before filing.
- 主要语言
- Python
- 星标
- 9
- 派生
- 2
- 平均合并
- 7 小时 22 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/envier 的其他 Issue
-
Add `examples`未关闭enhancement
难度 4/5 3-5 天 新手友好度 35/100
-
enhancement
难度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shards未关闭status/accepted type/bug
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
bug vector-store
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
EverMind-AI/Raven#1413 ·
维护者通常 1 天内回复
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS pools可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
维护者通常 2 天内回复