-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SerdeError deserializing list of optional #329
Comments
@yukinarit do you need/want any help on this? I'll need to implement a workaround soon as I have to ship something, but I'd rather make a PR here if you can point me in the right direction and we can get merged in next week or so 😁 |
@davetapley Sorry, I missed this. I will work on this next. |
@yukinarit FYI still present in v0.22.2 |
@yukinarit still present in 0.23.0 |
@yukinarit I did some more 👀 The Line 880 in 0aedb6f
I don't understand enough to know why it's generated, however as far as I can tell the only test which hits it is: Line 259 in 0aedb6f
It also looks like these are related: Tests: import logging
from dataclasses import dataclass
from typing import (
Optional,
Union,
)
from serde import (
init as serde_init,
logger,
serde,
)
from serde.json import from_json, to_json
logging.basicConfig(level=logging.WARNING)
logger.setLevel(logging.DEBUG)
serde_init(True)
@serde
@dataclass(unsafe_hash=True)
class ListUnionNone:
"""
List of optionals
"""
v: list[Union[str, None]] # noqa
def test_list_union_none() -> None:
v = ListUnionNone(['a', None, 'b'])
s = '{"v":["a",null,"b"]}'
assert s == to_json(v)
assert v == from_json(ListUnionNone, s)
@serde
@dataclass(unsafe_hash=True)
class ListOptional:
"""
List of optionals
"""
v: list[Optional[str]] # noqa
def test_list_optional() -> None:
v = ListOptional(['a', None, 'b'])
s = '{"v":["a",null,"b"]}'
assert s == to_json(v)
assert v == from_json(ListUnionNone, s) Both fail with Thanks! 🙏🏻 |
Changed AST representation to avoid using collections that contain Optional values per yukinarit/pyserde#329.
Seen on
0.9.7
but then updated and still present on0.10.2
(#315 is amazing BTW 👏🏻 👏🏻 👏🏻 ):The text was updated successfully, but these errors were encountered: