reagento / adaptix

An extremely flexible and configurable data model conversion library.
https://adaptix.readthedocs.io
Apache License 2.0
374 stars 23 forks source link

Key error when serializing TypedDict with total=False #172

Closed Tishka17 closed 2 years ago

Tishka17 commented 2 years ago
        class Book(typed_dict, total=False):
            name: str
            year: int

        factory = Factory()
        data = {
            "name": "hello",
        }
        raw = dict(name="hello")
        self.assertEqual(raw, factory.dump(data, Book))

Error:

  File "/home/tishka17/src/dataclass_factory/dataclass_factory/serializers.py", line 120, in <dictcomp>
    data_name: serializer(getter(data, field_name))
KeyError: 'year'