-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Optional constrained types do not work #493
Comments
I've also encountered this issue. Downgrading to 2.14.0 fixes it |
@jmspereira thanks for reporting this! I just wanted to confirm something. This only happens when it's an optional type right? That is, |
Some observations from when I was reproducing this:
|
Hey @guacs, yes it only happens with a union with optional types! |
Okay, so the reason for this was that the constraints for union types weren't being properly parsed after the changes in #491. I have a fix for this, and it should be included in the next release :) |
@guacs In my opinion, it will be respectful to other developers to yank the Another one example (perhaps already covered by the cases above): from typing import Annotated
from annotated_types import MinLen
from pydantic import BaseModel
from polyfactory.factories.pydantic_factory import ModelFactory
class Person(BaseModel):
pets: dict[int, Annotated[list[Annotated[str, MinLen(1)]], MinLen(1)]]
class PersonFactory(ModelFactory[Person]): ...
person_instance = PersonFactory.build() |
Yeah I think that'd be a good idea actually. Especially since the broken release only has the faulty PR as well. @provinzkraut what do you think? I think you have the permission to yank right? |
If anyone of y'all (@jmspereira, @albertferras-vrf or @olk-m) could test #499, that'd be great. I've added the tests for the cases covered here, but I may have missed some edge case (or an obvious one 😄). |
Description
Hey, I have a model that has a field that is a conlist or a None, in the last version of polyfactories, that stopped working because it is generating the wrong data (it generates a list with 3 lists inside instead of a list with 3 elements).
URL to code causing the issue
No response
MCVE
Steps to reproduce
No response
Screenshots
No response
Logs
No response
Release Version
2.14.1
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: