Is name=None correct for NodeImage constructor?
- 主要言語
- Python
- スター
- 2.1k
- フォーク
- 931
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 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 から始め、その name annotation を docs/examples/compute/create_ec2_node_custom_ami.py の None 値と比較します。pyright で例を確認し、その後、annotation と例のどちらが想定される API と一致するかを判断します。例と type hints が type-ignore の回避策を必要とせず一致すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, cloud
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100