dry-python / dry-python/returns

IOSuccess / IOFailure and match-case

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

Mô tả

I don't really see the point of `IOSuccess` and `IOFailure`. From one hand, `IOResult.from_value(1) == IOSuccess.from_value(1)`. Actually ,`IOSuccess.from_value(1) == IOFailure.from_value(1)`.
I would also expect some benefit when using it in a match-case. Something like:

```python
value = IOSuccess.from_value(1)
match value:
case IOSuccess(v): assert(v == 1)
case _: pass
```

However, the "correct" code is

```python
value = IOSuccess.from_value(1)
match value:
case IOResult(Success(v)): assert(v == 1)
case _: pass
```

Therefore, `IOSuccess` and `IOFailure` as aliases are quite confusing. Don't you think?

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

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

Hướng nghiên cứu

Start by locating the definitions of IOSuccess, IOFailure, IOResult, and Success, then reproduce both match-case examples and the equality comparisons from the issue. The intended behavior and whether these aliases should change are not decided here, so completion would require an agreed design and corresponding tests.

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
tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/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.