-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: generate() missing 1 required positional argument: 'params' #787
Comments
Hi! Thanks for the report. The I'm a bit surprised by your issue though, the API is supposed to be |
Sorry, I was in a hurry when I wrote this bug report. The full code is something like this:
I'm not sure why it's written like this (I'm not the author of that bit of code). |
I see ;) The "proper" way would be: emails = factory.Maybe(
factory.SelfAttribute('some_boolean_field'),
factory.List([factory.Faker('safe_email')]),
[],
) I guess we should make it easier to find in the docs; and maybe easier to write too… However, there seems to be a bug deeper down (see #786) in the Faker code which might fix the code you've got. |
Thanks for the snippet of the "proper" way. I'll update our code so we don't use a private API anymore. I don't think there's anything to do on the factory_boy side, so I'll close this issue. Thanks again! |
Unrolling the extra context for a declaration might depend on the declaration's internals; that's typically the case with factory.Maybe: the inner declarations might depend on the actual declaration used. This adds `evaluate_pre` and a `evaluate_post` entrypoints to declarations, more readable with regard to which build phase they are used in. Each of those will perform unrolling before calling the semi-public actual function entrypoint (self.evaluate() for evaluate_pre, self.call() for evaluate_post). As a side effect, this fixes the issues with factory.Faker() when called inside a factory.Maybe(). Closes #785 #786 #787 #788 #790 #796.
Unrolling the extra context for a declaration might depend on the declaration's internals; that's typically the case with factory.Maybe: the inner declarations might depend on the actual declaration used. This adds `evaluate_pre` and a `evaluate_post` entrypoints to declarations, more readable with regard to which build phase they are used in. Each of those will perform unrolling before calling the semi-public actual function entrypoint (self.evaluate() for evaluate_pre, self.call() for evaluate_post). As a side effect, this fixes the issues with factory.Faker() when called inside a factory.Maybe(). Closes #785 #786 #787 #788 #790 #796.
After upgrading from 3.0.1 to 3.1 I suddenly get a
TypeError: generate() missing 1 required positional argument: 'params'
.I have a
factory.LazyAttribute
that callsfactory.Faker('safe_email').generate()
conditionally. This worked before and now raises aTypeError
.This seems to be caused by commit f0a4ef0. Would it be possible to make
params
optional?The text was updated successfully, but these errors were encountered: