[minimal-repro-testcase] from v0.5.12 on, tuple fields get truncated
Closed this issue · 5 comments
Description
From v0.5.12 on, tuples get (sometimes?) truncated when deserializing. I think this is a major issue since there is no exception thrown; your data is just garbled. This has huge potential to make make whole data recording sessions useless as you only notice it when your data looks funny afterwards.
Everything works fine in v0.5.9; from v0.5.12, not.
This project is one of my absolute favorites by the way and thank you for it.
Serializing from tuples instead of lists is IMO a very common use case, as dataclass instances with lists cannot be hashable, i.e. cannot be used as a key in dictionaries for efficient lookup.
Code snippet that reproduces the issue
from dataclasses import dataclass
from dataclasses_json import dataclass_json, LetterCase, Undefined
from typing import Tuple
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass(frozen=True, eq=True)
class MyClass:
path: Tuple[int]
instance = MyClass((0, 1, 0))
asJson = instance.to_json()
fromJson = MyClass.from_json(asJson)
assert fromJson.path == (0,1,0)
- The assert succeeds in version
[0.5.9]
- The assert fails in versions
[0.5.12..0.6.1]
See also my pip environment which is not huge.
Describe the results you expected
That it just works...
Python version you are using
3.11.4
Environment description
boltons @ file:///work/ci_py311/boltons_1677685195580/work
brotlipy==0.7.0
certifi @ file:///croot/certifi_1683875369620/work/certifi
cffi @ file:///work/ci_py311/cffi_1676822533496/work
charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work
conda @ file:///croot/conda_1689269889729/work
conda-content-trust @ file:///work/ci_py311/conda-content-trust_1676851327497/work
conda-libmamba-solver @ file:///croot/conda-libmamba-solver_1685032319139/work/src
conda-package-handling @ file:///croot/conda-package-handling_1685024767917/work
conda_package_streaming @ file:///croot/conda-package-streaming_1685019673878/work
cryptography @ file:///croot/cryptography_1686613057838/work
dataclasses-json==0.6.1
idna @ file:///work/ci_py311/idna_1676822698822/work
jsonpatch @ file:///tmp/build/80754af9/jsonpatch_1615747632069/work
jsonpointer==2.1
libmambapy @ file:///croot/mamba-split_1685993156657/work/libmambapy
marshmallow==3.20.1
marshmallow-enum==1.5.1
mypy-extensions==1.0.0
packaging @ file:///croot/packaging_1678965309396/work
pluggy @ file:///work/ci_py311/pluggy_1676822818071/work
pycosat @ file:///work/ci_py311/pycosat_1676838522308/work
pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work
pyOpenSSL @ file:///croot/pyopenssl_1678965284384/work
PySocks @ file:///work/ci_py311/pysocks_1676822712504/work
requests @ file:///croot/requests_1682607517574/work
ruamel.yaml @ file:///work/ci_py311/ruamel.yaml_1676838772170/work
six @ file:///tmp/build/80754af9/six_1644875935023/work
tabulate==0.9.0
toolz @ file:///work/ci_py311/toolz_1676827522705/work
tqdm @ file:///croot/tqdm_1679561862951/work
typing-inspect==0.9.0
typing_extensions==4.8.0
urllib3 @ file:///croot/urllib3_1686163155763/work
zstandard @ file:///work/ci_py311_2/zstandard_1679339489613/work
@matt035343 I'll try to run the repro case tomorrow, but maybe you have an idea why this happens since you worked with tuple ser recently?
Confirmed - linked a PR that should fix this.
Circling back here - had a break from OSS due to high load at work. Will resume next week. Really sorry folks