adaptix icon indicating copy to clipboard operation
adaptix copied to clipboard

forward refs

Open Tishka17 opened this issue 5 years ago • 2 comments

closes #63 closes #24

Tishka17 avatar May 23 '20 20:05 Tishka17

refs must be set for each dataclass! (class "A" can be in several modules, and refs are set as stings with short name)

Tishka17 avatar May 23 '20 21:05 Tishka17

Related problem with get_type_hints. We need workaround for this code

from __future__ import annotations
from dataclasses import dataclass
from dataclass_factory import Factory


def main():
    @dataclass
    class ContainsInt:
        x: int

    @dataclass
    class Data:
        contents: ContainsInt

    factory = Factory()
    parsed = factory.load({"contents": {"x": 1}}, Data)
    assert parsed == Data(ContainsInt(x=1))


if __name__ == '__main__':
    main()

Tishka17 avatar Jul 07 '21 08:07 Tishka17