Hello, I want to take my comment from older closed issue.
I miss the ability to generate guaranteed unique values. I used to use the FactoryBoy library for factories and there is a Sequence
field for this purpose, which allows you to specify a function that will receive the next integer value at each call.
I would like to have a similar field in this library and would like to discuss a possible implementations.
I would like to hear feedback on the proposed solutions and can take on the implementation.
What are the possibilities I see:
@dataclass
class Person:
email: str
__random__
:class PersonFactory(DataclassFactory[Person]):
@classmethod
def email(cls) -> str:
return cls.__sequence__(lambda n: f'user{n}@domain.tld')
__random__
and Use
:class PersonFactory(DataclassFactory[Person]):
email = Use(DataclassFactory.__sequence__, lambda n: f'user{n}@domain.tld')
class PersonFactory(DataclassFactory[Person]):
email = Sequence(lambda n: f'user{n}@domain.tld')
It will be possible to generate guaranteed unique or sequential values.
I would like to hear feedback on the proposed solutions and can take on the implementation.
Perhaps the maintainers can suggest why this might be a bad idea or suggest the best way this can be built into the current codebase.
It might be worth discussing how the sequence should be reset.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too