reagento / adaptix

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

One field seems to be affecting another in some cases #207

Closed MarsBatya closed 3 months ago

MarsBatya commented 1 year ago
from dataclasses import dataclass

import dataclass_factory

@dataclass
class Hit:
    document: str
    text_match: int

@dataclass
class SearchResult:
    facet_counts: list # works fine if set as list[str]
    hits: list[Hit]

data = {
    "facet_counts": [],
    "hits": [
        {
            "document": "hi",
            "text_match": 578730054645710969
        },
    ]
}

factory = dataclass_factory.Factory()

search = factory.load(data, SearchResult)

print(f"{isinstance(search.hits[0], Hit)=}")
# expected: isinstance(search.hits[0], Hit)=True
# present: isinstance(search.hits[0], Hit)=False
MarsBatya commented 1 year ago

python 3.9.0 dataclass-factory==2.16

Eclips4 commented 1 year ago

python 3.9.0 dataclass-factory==2.16

The same on 3.10 & 3.11

zhPavel commented 3 months ago

Does not apply to the new major version