-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Create weight_conversion.py #3964
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
Conversation
Fix (this is the easiest method to comply with contirbuting.md requirements):
|
@xcodz-dot Thank you for your response so what should I do now as all checks have already passed. |
@dhruvmanila check this out |
@AnubhavSolanki, You can mention maintainers if you feel like your work is done |
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.
Naming Convention
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.
Great
so now can we merge it? |
Yeah wait for @dhruvmanila, only members can merge (I am just a guy helping people) |
Oh GOT IT... THANKS BTW |
@AnubhavSolanki, you can directly use the commit button near suggestions if you do not like manual working |
@dhruvmanila, check this if it meets your requirements |
@dhruvmanila, check this if it's ok. |
if to_type not in KILOGRAM_CHART or from_type not in WEIGHT_TYPE_CHART: | ||
raise ValueError( | ||
f"Invalid 'from_type' or 'to_type' value: {from_type!r}, {to_type!r}\n" | ||
f"Supported values are: {', '.join(WEIGHT_TYPE_CHART)}" | ||
) | ||
return value * KILOGRAM_CHART[to_type] * WEIGHT_TYPE_CHART[from_type] |
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 reason for this change is so that the static type checker mypy
does not complain that the function had no return statement.
If we did the try ... except ...
pattern, when the try
block raises an exception, we go to the except
block where we would normally just print a message. This would mean that the function returns None
implicitly, thus the mypy
error.
Hope you understand the choice, if not please feel free to ask any question.
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.
thank you got your point.. :)
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.
Awesome work! Thank you for your contribution.
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <[email protected]>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <[email protected]>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <[email protected]>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <[email protected]>
Describe your change:
Added a Weight Conversion Algorithm.
Checklist:
Fixes: #{$ISSUE_NO}
.