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

"adding height and weight for person provider" #1982

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

boopathinmc7217
Copy link

What does this change

Added Height and Weight for the person provider

What was wrong

How this fixes it

@@ -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:
Copy link
Contributor

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.

Copy link
Collaborator

@fcurella fcurella Jan 24, 2024

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.

Copy link
Author

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"
Copy link
Contributor

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?

Copy link
Contributor

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:
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Test height generation for person
Test height generation for person


def test_weight(self):
"""
Test weight generation for person
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Test weight generation for person
Test weight generation for person

@fcurella
Copy link
Collaborator

I'm not sure if it's appropriate to have this in person. Could it be a more generic "measures" provider with weight(min, max) and length(min, max)?

@boopathinmc7217
Copy link
Author

I'm not sure if it's appropriate to have this in person. Could it be a more generic "measures" provider with weight(min, max) and length(min, max)?

Agreed , we can support the measurements ,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants