-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
"adding height and weight for person provider" #1982
"adding height and weight for person provider" #1982
Conversation
@@ -328,3 +328,31 @@ def suffix_female(self) -> str: | |||
def language_name(self) -> str: | |||
"""Generate a random i18n language name (e.g. English).""" | |||
return self.random_element(self.language_names) | |||
|
|||
def height(self, fmt: str = "ft") -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt
should probably be of type LiteralString
in this case if it only supports a limited set of values. Additionally, I would argue that invalid values should not return imperial units, but just fail. Besides this, I am not sure whether defaulting to ft should really be done or if we have a way to use the current locale for it - speaking of myself, I never actually have to deal with ft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the unit should be according to the locale. If a locale only uses one unit (eg: Italy only uses Metric), I wouldn't even have the parameter, and reserve it only for those locales that use both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will look into way for using current locale
|
||
""" | ||
if fmt == "cm": | ||
return f"{self.random_number(digits=2)} cms" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the trailing s really make sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the trailing s really make sense here?
No. There is no plural for it...
else: | ||
return f"{self.random_number(digits=1)}'{self.random_number(digits=2)}\"" | ||
|
||
def weight(self, fmt: str = "lbs") -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue the same as for the height regarding parameter handling here.
|
||
def test_height(self): | ||
""" | ||
Test height generation for person |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test height generation for person | |
Test height generation for person |
|
||
def test_weight(self): | ||
""" | ||
Test weight generation for person |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test weight generation for person | |
Test weight generation for person |
I'm not sure if it's appropriate to have this in |
Agreed , we can support the measurements , |
What does this change
Added Height and Weight for the person provider
What was wrong
How this fixes it