Just noticed this playing with Try (Python 3.9.7, expression 1.1.0):
Python 3.9.7 (default, Aug 31 2021, 13:28:12)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> from expression import Failure, Success
>>> x = Success(10)
>>> y = Failure(ValueError())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vputz/.cache/pypoetry/virtualenvs/plugin-playground-TQ0vVnN3-py3.9/lib/python3.9/site-packages/expression/core/result.py", line 199, in __init__
super().__init__(str(error))
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Looks like in result.py:199:
class Error(Result[TSource, TError], ResultException):
"""The Error result case class."""
def __init__(self, error: TError) -> None:
super().__init__(str(error))
self._error = error
... it looks like it's trying to call the Result version of __init__ first (which makes sense; it's first in the parent list) instead of Error.__init__, which indeed takes a string as an argument.
Changing the order of parents to:
class Error(ResultException, Result[TSource, TError]):
Avoids the error:
>>> from expression import Failure, Success
>>> x = Success(10)
>>> y = Failure(ValueError())
...although there may be another way to resolve it which may be preferable.
Just noticed this playing with Try (Python 3.9.7, expression 1.1.0):
Looks like in
result.py:199
:... it looks like it's trying to call the
Result
version of__init__
first (which makes sense; it's first in the parent list) instead ofError.__init__
, which indeed takes a string as an argument.Changing the order of parents to:
Avoids the error:
...although there may be another way to resolve it which may be preferable.