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

JSON and Fixed Width argument group and parser support. #1247

Merged
merged 15 commits into from
Aug 19, 2020
Merged

JSON and Fixed Width argument group and parser support. #1247

merged 15 commits into from
Aug 19, 2020

Conversation

johnbrandborg
Copy link
Contributor

@johnbrandborg johnbrandborg commented Aug 19, 2020

What does this changes

The new Argument Groups is a much cleaner way to handle parsing arguments to provider methods when building data structures like DSV, JSON and Fixed Width. It also allows for the JSON provider to now accept a Dictionary that utilizes the Argument Groups, which is a much simpler way to build complex data structures.

fake.set_arguments('top_half', {'min_value': 50,'max_value': 100})

fake.json(data_columns={'Name': 'name', 'Score': 'pyint:top_half'})
fake.fixed_width(data_columns=[(20, 'name'), (3, 'pyint:top_half')])

If string tokens are used then complex Strings can be created by using pystr_format under the hood.

fake.set_arguments('red_rgb', {'hue': 'red', 'color_format': 'rgb'})
fake.json(data_columns={'Address': 'address', 'Feature': '### - {{ color:red_rgb }}'})

All previous support for lists with tuple records is still in tacked and will not be broken. More tests have been added to ensure absolutely safety for anyone that begins to use JSON with list format or dict format, and Fixed Width generation.

crd and others added 15 commits June 21, 2020 13:58
)

* Implement nonbinary Person Provider

* Address flake8 and isort findings

* Fix import ordering in tests

* Add tests for en Provider to test preexisting suffix scenario

* Refine tests for en Provider
* Add safe_domain_name() to Internet Provider

* Apply DRY to safe domain generation

* Add a test for safe email generation
some grammar fix
* 💂 Fix max_value/positive pyfloat interaction

When pyfloat(max_value=100, positive=True) is called, it sometimes
returns negative numbers, which is unexpected.

To fix it, we just need to "cap" our internal minimum value to zero.

This does leave `pyfloat(max_value=100, min_value=-100, positive=True)`
as a call that secretly moves the min_value up to 0 though.

Fixes #1212.

* 💥 Forbid pyfloat call with incompatible arguments

`pyfloat(positive=True, min_value=-1)` will now throw a ValueError,
since the combination of a request for a positive number, yet a negative
minimum value is probably not what the caller intended.
* Add ja_JP kana_names

* Reformat and Add links

* fix PEP8
* Builder module

* Move to Misc as Methods

* Allow JSON to produce single entry

* json and fixed_width tests

* Improved structure creation and tests

* correcting E231

* Value only lists

* fix E303

* Improved docstrings
@fcurella
Copy link
Collaborator

Nice work! Thank you! ✨

@fcurella fcurella merged commit ecc2d4d into joke2k:master Aug 19, 2020
IlfirinPL pushed a commit to IlfirinPL/faker that referenced this pull request Apr 9, 2021
* Extend Person Provider to support nonbinary suffixes and prefixes (joke2k#1206)

* Implement nonbinary Person Provider

* Address flake8 and isort findings

* Fix import ordering in tests

* Add tests for en Provider to test preexisting suffix scenario

* Refine tests for en Provider

* Close joke2k#1208. Update setup.py `python_requires`

* Add safe domain names (joke2k#1209)

* Add safe_domain_name() to Internet Provider

* Apply DRY to safe domain generation

* Add a test for safe email generation

* Update __init__.py (joke2k#1217)

some grammar fix

* 💂 Fix max_value/positive pyfloat interaction (joke2k#1218)

* 💂 Fix max_value/positive pyfloat interaction

When pyfloat(max_value=100, positive=True) is called, it sometimes
returns negative numbers, which is unexpected.

To fix it, we just need to "cap" our internal minimum value to zero.

This does leave `pyfloat(max_value=100, min_value=-100, positive=True)`
as a call that secretly moves the min_value up to 0 though.

Fixes joke2k#1212.

* 💥 Forbid pyfloat call with incompatible arguments

`pyfloat(positive=True, min_value=-1)` will now throw a ValueError,
since the combination of a request for a positive number, yet a negative
minimum value is probably not what the caller intended.

* Update bban_format for country FI (joke2k#1220)

Fixes joke2k#1219.

* Fix person.ja_JP kana and roman characters (joke2k#1221)

* Add ja_JP kana_names

* Reformat and Add links

* fix PEP8

* JSON and Fixed_Width Structures (joke2k#1223)

* Builder module

* Move to Misc as Methods

* Allow JSON to produce single entry

* json and fixed_width tests

* Improved structure creation and tests

* correcting E231

* Value only lists

* fix E303

* Improved docstrings

* Add Argument Group references

* Add Argument Group and Parser Support

* Fixed handing of integers and floats

* Addressed Flake8 findings

* Better Examples and Samples

Co-authored-by: Cory Donnelly <[email protected]>
Co-authored-by: Flavio Curella <[email protected]>
Co-authored-by: Pavel E. Petrov <[email protected]>
Co-authored-by: coiax <[email protected]>
Co-authored-by: ALMP-SallaH <[email protected]>
Co-authored-by: Yohei Ema <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants