from dataclasses import dataclass
from mashumaro import DataClassDictMixin
@dataclass
class DataClass(DataClassDictMixin):
x: dict[int, int] | list[float]
print(DataClass.from_dict({"x": {"1.1": "2.2"}})) # will raise InvalidFieldValue
On Python <3.12 this code works as expected and prints: DataClass(x=[1.1]). To fix this issue we can use different names for keys and values inside comprehensions or wait for the bug fix in CPython itself before the final release.
Description
Some tests are failed on Python 3.12.0rc1 and the root cause is the bug in comprehension inlining:
What I Did
On Python <3.12 this code works as expected and prints:
DataClass(x=[1.1])
. To fix this issue we can use different names for keys and values inside comprehensions or wait for the bug fix in CPython itself before the final release.