You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even the simplest model with an optional list appears to not work. Instead of generating a valid coverage including None and a random string, a validation error is raised. Worth noting that it seems to be making a list of list of str, rather than a list of string.
frompydanticimportBaseModelfromtypingimportOptional, List, Union# Note: Optional is included as I tried it as well, realize that it is also just a union.frompolyfactory.factories.pydantic_factoryimportModelFactoryclassExampleModel(BaseModel):
values: Union[List[str], None]
classExampleModelFactory(ModelFactory):
__model__=ExampleModelif__name__=="__main__":
print(list(ExampleModelFactory.coverage()))
Steps to reproduce
1. Install dependencies (I'm using 1.10.17 and polyfactory 2.16.0)
2. Run the example.
3. Get a validation failure in coverage:
pydantic.error_wrappers.ValidationError: 1 validation error for ExampleModel
values -> 0
str type expected (type=type_error.str)
Also sorry if the post was a little dorked, I tried to edit it to make it right but I don't report on Github very frequently, hopefully this'll improve with practice.
Description
Even the simplest model with an optional list appears to not work. Instead of generating a valid coverage including
None
and a random string, a validation error is raised. Worth noting that it seems to be making a list of list of str, rather than a list of string.URL to code causing the issue
https://github.com/RLC92/polyfactory_error_submission
MCVE
Steps to reproduce
Screenshots
No response
Logs
No response
Release Version
2.16.0
Platform
Note
While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.
Check out all issues funded or available for funding on our Polar.sh dashboard
The text was updated successfully, but these errors were encountered: