Closed tom300z closed 3 weeks ago
@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 https://github.com/litestar-org/polyfactory/blob/67c57208de5ce993bdb2c7888864ac4e71964511/polyfactory/value_generators/constrained_collections.py#L49 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
Screenshots
No response
Logs
No response
Release Version
v2.16.2
Platform