litestar-org / litestar-org/polyfactory
Enhancement: have Trait/HiddenField only there to feed the post_generate of other fields
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
### Summary
Hi !
Not sure if Documentation Request or Enhancement, took the second one as I did not found it...
I want to use [Faker's local_latlng](https://faker.readthedocs.io/en/master/providers/faker.providers.geo.html#faker.providers.geo.Provider.local_latlng) to feed several fields, latitude, longitude, city.
I think the way to go is to use post_generate, however now I don't see a better way to do so then to call the function X times and then access the item of the tuple returned by the function by position.
I think it would be cleaner if PolyFactory was supporting some kind of HiddenField (maybe all fields prefixed by `__` ?) to get the value, store the tuple as attribute there, use it to feed other fields, but then never reflect it in model_dump() or other instance logic.
I may have missed a functionality somewhere else...
### Basic Example
_No response_
### 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 by tracing the post_generate hook and the model_dump behavior referenced in the issue, then inspect how Trait and HiddenField are represented. Define how a hidden value feeds other fields and verify that it is excluded from model_dump() and other instance output while remaining available to dependent generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100