litestar-org / litestar-org/polyfactory
Enhancement: add interface for generating arbitrary type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
### Summary
It is useful for custom field generation or testing to generating an arbitrary type to reuse polyfactory generation logic e.g. `dict[str, list[int]]`. This is not possible without knowledge of internals or creating throwaway model.
### Basic Example
Before
```py
BaseFactory.get_field_value(FieldMeta.from_type(dict[int, str]])
```
After
```py
BaseFactory.get_field_value(dict[int, str])
```
with appropriate overloads to have proper return type. Alternatively could add new method
### 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 BaseFactory.get_field_value and FieldMeta.from_type, which the issue identifies as the current path for generating values. Trace the existing generation logic and define the public entry point and overload behavior for arbitrary types such as dict[int, str]; done means callers can use the proposed API without constructing FieldMeta or a throwaway model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100