python providers should use value_types as a keyword argument
See original GitHub issueSome of the python providers use a slightly unusual function call signature like this:
fake.pydict(nb_elements=10, variable_nb_elements=True, *value_types)
fake.pylist(nb_elements=10, variable_nb_elements=True, *value_types)
This leads to some usage problems with factory_boy (https://github.com/FactoryBoy/factory_boy/issues/387).
IMHO it would be much more convenient to be able to call the python providers with value_types
as a keyword argument like so:
fake.pydict(nb_elements=10, variable_nb_elements=True, value_types=['str'])
fake.pylist(nb_elements=10, variable_nb_elements=True, value_types=['str'])
I know this would introduce a braking change to the python provider api, but if this is acceptable I can try to provide a PR.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
PEP 692 – Using TypedDict for more precise **kwargs typing
The new approach revolves around using TypedDict to type **kwargs that comprise keyword arguments of different types.
Read more >faker.providers.python — Faker 15.3.4 documentation
class faker.providers.python. ... Parameters: enum_cls – The Enum type to produce the value for. ... is use variable number of elements for dictionary....
Read more >Entity Property Reference - App Engine - Google Cloud
Optional keyword argument: compressed . PickleProperty, Value is a Python object (such as a list or a dict or a string) that is...
Read more >typing — PyTorch/Elastic master documentation
Internal helper functions: these should never be used in code outside this module. * _SpecialForm and its instances (special forms): Any, NoReturn, ...
Read more >_ncs - NSO API 6.0 - Document - Cisco Developer
There should be no need to call this function directly. It is called internally when the Python module is loaded. Keyword arguments: name...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree this confused me a little bit.
At first I was doing this
Figured out you should not use the keywords if you want to specify value_types
I hope this helps someone going through the same issue.
Hi @mhubig, it seems reasonable. To handle the backcompatibility we could use some signature like that:
Combining
values_types
andallowed_types
carefully.