returns
returns copied to clipboard
Success(None) and Some(None) fails to load from pickle
Bug report
What's wrong
It appears returns containers fail to load from serialized pickle form when the inner value is None.
I wrote a quick test script:
import pickle
from returns.result import Success, Failure
from returns.maybe import Some
assert(pickle.loads(pickle.dumps(Success(None))) == Success(None))
assert(pickle.loads(pickle.dumps(Failure(None))) == Failure(None))
assert(pickle.loads(pickle.dumps(Some(None))) == Some(None))
Here's the stacktrace
$ python ./test.py
Traceback (most recent call last):
File "/home/yuki/cum/./test.py", line 6, in <module>
assert(pickle.loads(pickle.dumps(Success(None))) == Success(None))
File "/nix/store/rsyzznrv5jg9dx7yj26lf4yjybmafba2-python3-3.9.12-env/lib/python3.9/site-packages/returns/primitives/container.py", line 34, in __eq__
return container_equality(self, other) # type: ignore
File "/nix/store/rsyzznrv5jg9dx7yj26lf4yjybmafba2-python3-3.9.12-env/lib/python3.9/site-packages/returns/primitives/container.py", line 61, in container_equality
self._inner_value == other._inner_value, # type: ignore # noqa: WPS437
AttributeError: _inner_value
So far I've tested Success, Failure, Some and all three of them fail the same way.
How is that should be
As shown in the test script, returns container should be "recreated" properly including its None inner value from the pickled form.
System information
-
pythonversion:3.9.12 -
returnsversion:0.19.0 -
mypyversion:0.950