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

feat: force to generate for non-required fields #91

Merged
merged 7 commits into from
Jan 28, 2024

Conversation

elecay
Copy link
Contributor

@elecay elecay commented Dec 20, 2023

Changes:

  • Allow to create strings of any length. If the generated string ends with a space, it will be changed to a dot (eg. 'at.' instead of 'at '. Just to avoid confusion.
  • Allow to generate data even for non-required fields (similar to: Polyfactory allow_none_optionals). The value should be a float between 0.0 and 1.0, indicating the probability of allowing getting a None value. 0.0 means "0% chances of getting a None", 1.0 means "100% chances of getting a None", 0.5 means "50% chances of getting a None", etc. The default is 0.5.
  • Minor improvements

"__internal__": {"List": List, "Union": Union, "Tuple": Tuple},
},
initial_state: Dict[str, Any] = {},
context: Dict[str, Any] = MappingProxyType(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcosmadr
Copy link

This feature to force non required fields is something that I was also looking for, would you have an ETA to release this?

@albertferras-vrf
Copy link

albertferras-vrf commented Jan 24, 2024

@ghandic could you check this? Would really like to have this feature available included.
Thanks :)

@ghandic
Copy link
Owner

ghandic commented Jan 24, 2024

Hey, I've added feedback to the PR, would like to keep the Lorem strings and also have the allow_none_optionals be a float [0-1] which sets the probability for none to be provided as optionals

@elecay
Copy link
Contributor Author

elecay commented Jan 24, 2024

Hey, I've added feedback to the PR, would like to keep the Lorem strings and also have the allow_none_optionals be a float [0-1] which sets the probability for none to be provided as optionals

Ey @ghandic. I cannot see any feedback in the PR. Anyway:

  1. I suppose we can keep the Lorem as the base string (maybe create substrings of it?). The main thing is that currently, it is not possible to create a string of a specific range (or lower than 3).

  2. Not sure about what you said with "allow_none_optionals be a float [0-1] which sets the probability for none to be provided as optionals". The whole idea is to force to a non-null value. In the description of the PR you can see the behavior with Polyfactory.

@ghandic
Copy link
Owner

ghandic commented Jan 24, 2024

Must be issues with GH mobile, these are my comments

image
image

@albertferras-vrf
Copy link

albertferras-vrf commented Jan 24, 2024

@ghandic the Pending label suggests that you didn't submit your Review. You have a 'draft review' with comments in it but need to submit it (approve/reject/requestchanges) so that others can see it :)
Screenshot 2024-01-24 at 17 23 43

jsf/schema_types/string.py Outdated Show resolved Hide resolved
jsf/schema_types/base.py Outdated Show resolved Hide resolved
@elecay
Copy link
Contributor Author

elecay commented Jan 25, 2024

@ghandic changes applied.

jsf/schema_types/string_utils/content_type/text__plain.py Outdated Show resolved Hide resolved
jsf/schema_types/base.py Outdated Show resolved Hide resolved
@ghandic
Copy link
Owner

ghandic commented Jan 25, 2024

Overall looking good, I'll work on another PR to spice up the lorem a little bit after this is merged

@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (5cbcd0d) 99.19% compared to head (90c6297) 99.21%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   99.19%   99.21%   +0.02%     
==========================================
  Files          31       31              
  Lines        1116     1148      +32     
==========================================
+ Hits         1107     1139      +32     
  Misses          9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ghandic ghandic merged commit 4c935d6 into ghandic:main Jan 28, 2024
4 checks passed
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.

5 participants