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
@tom300z thanks for reporting this! I checked, and I couldn't really see a good reason to have it default to 1. Some of the tests check that the length of the collection from handle_constrained_collection is greater than 0, but I think that's incorrect. It should be checking that the length is greater than or equal to 0. If I make that change, the tests are all passing as well. So I think it should be fine to not default to 1 even if the random length we get is 0.
Description
When constraining a list to be empty (max_length=0):
a recursion error occurs.
The problem seems to be in
polyfactory/polyfactory/value_generators/constrained_collections.py
Line 49 in 67c5720
where a default length of 1 is used if the randomly picked length (always 0) is falsy. @Goldziher do you remember why this default exists?
URL to code causing the issue
No response
MCVE
Steps to reproduce
1. Install polyfactory & pydantic (v2) 2. Run example code
Screenshots
No response
Logs
No response
Release Version
v2.16.2
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: