Skip to content
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

[new]: faker(what, localization, options) #72

Closed
2 tasks done
unytics opened this issue Apr 11, 2023 · 3 comments
Closed
2 tasks done

[new]: faker(what, localization, options) #72

unytics opened this issue Apr 11, 2023 · 3 comments
Labels
new-bigfunction Suggest a New BigFunction

Comments

@unytics
Copy link
Owner

unytics commented Apr 11, 2023

Check the idea has not already been suggested

Edit the title above with self-explanatory function name and argument names

  • The function name and the argument names I entered in the title above seems self explanatory to me.

BigFunction Description as it would appear in the documentation

Use https://faker.readthedocs.io/ to generate fake data.

Code should look something like:

import json
from faker import Faker
fake = Faker(localization)
kwargs = json.loads(options)
return getattr(fake, what)(**kwargs)

Examples of (arguments, expected output) as they would appear in the documentation

  • what='name', localization='it_IT', options=null --> Elda Palumbo
@unytics unytics added the new-bigfunction Suggest a New BigFunction label Apr 11, 2023
@shivam221098
Copy link
Contributor

shivam221098 commented Apr 12, 2023

Hi @unytics,

I think the parameter options will be irrelevant for the users. Because users have to look at the Faker docs, only then will they be able to use those parameters. Otherwise given function will raise an error if someone enters any parameter. A null can be returned but that will not give a user a clear idea of what's happening. The options parameter will only be useful for those who have the idea of Faker.

For example:
Suppose -

localization = "it_IT"
what = "name"
options = '{"x": null}'

if someone uses this option then the function will generate TypeError: Provider.name() got an unexpected keyword argument 'x'. We can handle this error and None can be returned. But that will not let the user know what he did wrong.

@unytics
Copy link
Owner Author

unytics commented Apr 12, 2023

Hello @shivam221098

You're right. Let's remove ˋoptions` parameter

@unytics
Copy link
Owner Author

unytics commented Apr 14, 2023

awesome work @shivam221098 .

closing the issue

@unytics unytics closed this as completed Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-bigfunction Suggest a New BigFunction
Projects
None yet
Development

No branches or pull requests

2 participants