litestar-org/polyfactory

Enhancement: support constraints for a `dict` type

AIGeneratedUsername opened this issue · 0 comments

Summary

A valid model:

from typing import Annotated
from annotated_types import MinLen
from pydantic import BaseModel
from polyfactory.factories.pydantic_factory import ModelFactory

class Person(BaseModel):
    pets_names: Annotated[dict[str, str], MinLen(1)]


class PersonFactory(ModelFactory[Person]):
    __model__ = Person


PersonFactory.build()

Error:

polyfactory.exceptions.ParameterException: received constraints for unsupported type dict[str, str]

Funding

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
Fund with Polar