File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1010)
1111
1212
13- def to_grams (weight , unit ):
13+ def to_grams (weight , unit ) -> int :
1414 """
15- Convert the given weight to kilograms .
15+ Convert the given weight to integer grams .
1616 """
1717 try :
1818 if weight < 0 :
@@ -21,13 +21,13 @@ def to_grams(weight, unit):
2121 raise TypeError (_ ("Invalid value '{weight}' for weight (must be a number)" ).format (weight = weight ))
2222
2323 if unit == WeightUnitChoices .UNIT_KILOGRAM :
24- return weight * 1000
24+ return int ( weight * 1000 )
2525 if unit == WeightUnitChoices .UNIT_GRAM :
26- return weight
26+ return int ( weight )
2727 if unit == WeightUnitChoices .UNIT_POUND :
28- return weight * Decimal (453.592 )
28+ return int ( weight * Decimal (453.592 ) )
2929 if unit == WeightUnitChoices .UNIT_OUNCE :
30- return weight * Decimal (28.3495 )
30+ return int ( weight * Decimal (28.3495 ) )
3131 raise ValueError (
3232 _ ("Unknown unit {unit}. Must be one of the following: {valid_units}" ).format (
3333 unit = unit ,
You can’t perform that action at this time.
0 commit comments