litestar-org / litestar-org/polyfactory
Enhancement: "Allow None Optionals" for a single field
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
### Summary
I have a single field which is marked as optional. Is there a way to indicate that it should always be generated by polyfactory?
### Basic Example
```
class AppointmentRequest(PydanticBaseModel):
doctor_email: EmailStr | None
class AppointmentRequestFactory(ModelFactory[AppointmentRequest]):
# doesn't work
doctor_email: EmailStr
```
### Drawbacks and Impact
_No response_
### Unresolved questions
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ModelFactory entry point and reproduce the AppointmentRequest example to inspect how optional fields are generated. The change is done when a single optional field can be configured to always receive a non-None generated value without changing the default behavior of other optional fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100