Bug: Typo in `field_meta.py` ?
Leobouloc opened this issue · 3 comments
Description
By analogy, I assume the line:
"max_length": getattr(value, "max_length", getattr(value, "max_length", None)),
should be:
"max_length": getattr(value, "max_length", getattr(value, "max_items", None)),
(if it is not a typo, the second getattr
is redundant and could be removed)
polyfactory/polyfactory/field_meta.py
Lines 211 to 212 in b479e4a
URL to code causing the issue
polyfactory/polyfactory/field_meta.py
Line 211 in b479e4a
MCVE
No response
Steps to reproduce
No response
Screenshots
No response
Logs
No response
Release Version
2.12.0
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)
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 Litestar dashboard
- If you would like to see an issue prioritized, make a pledge towards it!
- We receive the pledge once the issue is completed & verified
- This, along with engagement in the community, helps us know which features are a priority to our users.
@Leobouloc thanks! It's both a bug and not a bug at the same time 😄 This was included to handle parsing of constraints for pydantic v1, but the logic for v1 of pydantic doesn't use the FieldMeta.parse_constraints
method due to it needing some specialized logic in how they're handled. Hence, no one's had any validation issues so far.
If you're willing, feel free to raise a PR to fix it :)
Hi, Thanks for your answer. I would be glad to contribute, but am afraid I don't really understand the inner workings of the package ?
Concerning your answer, are you saying that max_length
should be max_items
or are you suggesting larger changes ?
I would be glad to contribute, but am afraid I don't really understand the inner workings of the package ?
That's completely fine! You can still give it a go and if you need any help, feel free to ask here or in discord.
Concerning your answer, are you saying that
max_length
should bemax_items
or are you suggesting larger changes ?
I think we can just remove that check for max_items
and min_items
from there. It's only for v1 and since we're not using parse_constraints
for v1, there's no reason to keep them there.
EDIT: Also, there are larger changes with respect to how v1 is handled that are planned which is being tracked in #435. I haven't been able to really get it to work yet because of how the API of pydantic v1 works.