allmonday / pydantic2-resolve

A hierarchical, schema-based solution for fetching and crafting data, from simple to complicated.

Home Page:https://allmonday.github.io/pydantic-resolve/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sequence type does not resolve

Dambre opened this issue · comments

commented

Sequence field does not resolve. After digging into internals it seems it does not collect it as valid type when checking for eligible objects. Reproduce simply:

class A(BaseModel):
    x: Sequence[str]

pydantic2-resolve=2.1.1

could you provide a more detailed test case? at my side

from pydantic import BaseModel
from pydantic_resolve import Resolver
from typing import Sequence
import pytest

class A(BaseModel):
    y: Sequence[str]

    x: Sequence[str] = []
    def resolve_x(self):
        return ['a', 'a']

@pytest.mark.asyncio
async def test_sequence():
    a = A(y=['1'])
    a = await Resolver().resolve(a)
    assert a.x == ['a', 'a']
    assert a.y == ['1']

this works.