apache / apache/libcloud

Is name=None correct for NodeImage constructor?

Đang mở
#2,075 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
2.1k
Fork
931
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
4

Mô tả

## 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với NodeImage trong libcloud/compute/base.py và so sánh chú thích name của nó với giá trị None trong docs/examples/compute/create_ec2_node_custom_ami.py. Kiểm tra ví dụ bằng pyright, sau đó quyết định xem chú thích hay ví dụ phù hợp với API dự kiến. Hoàn tất khi ví dụ và type hints thống nhất mà không cần workaround type-ignore.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api, cloud
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.