Create weight_conversion.py#3964
Create weight_conversion.py#3964dhruvmanila merged 14 commits intoTheAlgorithms:masterfrom AnubhavSolanki:master
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 |
|
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.
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.
thank you got your point.. :)
dhruvmanila
left a comment
There was a problem hiding this comment.
Awesome work! Thank you for your contribution.
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
* Create weight_conversion.py * Update weight_conversion.py Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Describe your change:
Added a Weight Conversion Algorithm.
Checklist:
Fixes: #{$ISSUE_NO}.