If to use a Schema instance twice, a Factory will try to use the parser of the first parsed field on the others, although they can be of a different type
from dataclasses import dataclass
from dataclass_factory import Factory, Schema
@dataclass
class Cls:
a: tuple
b: str
schema = Schema()
factory = Factory(schemas={
str: schema,
tuple: schema,
})
data = {'a': ('some', 'words'), 'b': 'hello world'}
cls = factory.load(data, Cls)
assert isinstance(cls, Cls) # True
assert isinstance(cls.a, tuple) # True
assert isinstance(cls.b, str), 'cls.b is a tuple' # False
A Factory with schemas for each type parses as expected
python3.9.6 dataclass-factory==2.11
If to use a Schema instance twice, a Factory will try to use the parser of the first parsed field on the others, although they can be of a different type
A Factory with schemas for each type parses as expected