dbrattli/Expression

__str__ and __repr__ of Failure & Success

Closed this issue · 1 comments

Describe the bug
When using str or repr on Try, it prints the representations of the parent class

To Reproduce

from expression import Try, Success, Failure
print( Success(8) )
print( Failure(8) )

Output:
Ok 8
Error 8

Expected behavior
Output:
Success 8
Failure 8

Additional context

  • OS [e.g. WSL 2]
  • Expression version [e.g 4.3.0]
  • Python version [e.g. 3.10]

Hey, thanks for opening this issue. I'm adding a fix for this now, just to tell that both Result and Try works a bit differently in Expression v5. Try is not an alias of Result, but subclasses Result in order to inherit all the member method handling. This mean that Try still have the ok and error cases when pattern matching. Haven't found a way around this yet without making a full reimplementation. I'll consider a way to fix this if I can find one going forwards.