precice / precice/python-bindings
Improve errors from `convert` function
还没有人认领这个 Issue。
- 主要语言
- Cython
- 星标
- 30
- 派生
- 19
- PR 合并指标
- 30 天内没有已合并 PR
描述
The error return by the convert function is not helpful at the moment. I stumbled over this when I organized my participant names in an Enum
class ParticipantNames(Enum):
MASS_LEFT = "Mass-Left"
MASS_RIGHT = "Mass-Right"
One has to pass, for example, ParticipantNames.MASS_LEFT.value to the API. But I forgot the .values part, which led to an errors similar to
>>> precice.Interface(1,2,3,4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cyprecice/cyprecice.pyx", line 87, in cyprecice.Interface.__cinit__
File "cyprecice/cyprecice.pyx", line 24, in cyprecice.convert
TypeError: Could not convert.
I think it would be good to tell the user which type was received from the API and which types are supported here. If I would have known that I provided a <enum 'ParticipantNames'> instead of a <class 'str'> this would have helped me a lot debugging.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 cyprecice/cyprecice.pyx 的 convert 函数(第 15-24 行)开始,在需要字符串的位置传入一个 Enum 成员,以重现该失败。更新错误行为,使其标识接收到的类型和受支持的类型,然后根据 issue 中的 Interface 示例验证生成的消息。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 78/100