Closed Fatal1ty closed 3 months ago
This adds support for types.MappingProxyType:
types.MappingProxyType
from types import MappingProxyType from mashumaro.codecs import BasicDecoder, BasicEncoder decoder = BasicDecoder(MappingProxyType[int, float]) encoder = BasicEncoder(MappingProxyType[int, float]) assert repr(decoder.decode({"42": "42"})) == "mappingproxy({42: 42.0})" assert encoder.encode(MappingProxyType({42: 42.0})) == {42: 42.0}
from dataclasses import dataclass from types import MappingProxyType from mashumaro import DataClassDictMixin @dataclass class MyClass(DataClassDictMixin): x: MappingProxyType[int, float] obj = MyClass.from_dict({"x": {"42": "42"}}) assert repr(obj) == "MyClass(x=mappingproxy({42: 42.0}))" assert repr(obj.to_dict()) == "{'x': {42: 42.0}}"
This adds support for
types.MappingProxyType
: