Is name=None correct for NodeImage constructor?
- 主要语言
- Python
- 星标
- 2.1k
- 派生
- 931
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 4
描述
## Summary
If someone copy-pastes code from [this example](https://github.com/apache/libcloud/blob/v3.8.0/docs/examples/compute/create_ec2_node_custom_ami.py#L22), they will get type errors in a type checker like [pyright](https://github.com/microsoft/pyright).
## Detailed Information
The type hints for NodeImage say that `name` is a `str`:
https://github.com/apache/libcloud/blob/v3.8.0/libcloud/compute/base.py#L451
However, in one of the examples in docs, `name` is set to `None`:
https://github.com/apache/libcloud/blob/v3.8.0/docs/examples/compute/create_ec2_node_custom_ami.py#L22
https://libcloud.readthedocs.io/en/stable/compute/examples.html#create-ec2-node-using-a-custom-ami
This means that a type-checker like pyright will complain if you follow this example.
Should the type hint and/or the example be changed?
My workaround was to add `# type: ignore` to silence the warning, but I figured I can open an issue in case someone else might run into the same thing.
贡献指南
调研方向
从 libcloud/compute/base.py 中的 NodeImage 开始,并将其名称注解与 docs/examples/compute/create_ec2_node_custom_ami.py 中的 None 值进行比较。使用 pyright 检查该示例,然后确定注解或示例是否符合预期的 API。完成的标准是示例与类型提示一致,且不需要使用 type-ignore 变通方案。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- api, cloud
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100