Closed nk9 closed 2 years ago
As stated in the documentation of the fuzzy generators (https://factoryboy.readthedocs.io/en/stable/fuzzy.html), you should prefer migrating to factory.Faker
instead. Your code should look something like this afterwards, see https://faker.readthedocs.io/en/master/providers/faker.providers.python.html#faker.providers.python.Provider.pyint:
obj_id = factory.Faker('pyint', min_value=int(4e6), max_value=int(5e6))
You have to explicitly cast the values to int
here as well, due to the function signature expecting int
values.
Thanks, I hadn't noticed that detail about the fuzzy
generators. The new style is quite verbose, so I've wrapped it in my own function with positional arguments and it's working well.
Description
I am using the following code to generate fuzzy integers in a factory today:
After upgrading to Python 3.10, this results in a deprecation warning:
I have tried passing integers instead of floats (e.g.
int(4e6)
and4000000
), but neither fix the warning. And they're both kind of annoying to have to type anyway.Notes
Presumably, the solution is to cast the variables using
int()
before passing them torandrange()
. More info in this Python library bug.