dry-python / dry-python/returns

IOSuccess / IOFailure and match-case

Aperta
#2,355 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
4.4k
Fork
155
Merge medio
2h 27m
PR unite (30g)
22

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.