dgrant / django_recipes

Assert statement used outside of tests BAN-B101
Security
Major
4 years ago4 years old
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
 56    return an (integer, numerator, denominator) tuple.
 57    """
 58
 59    assert x >= 0, "_to_frac only works on positive numbers." 60    orig_x = x
 61    intpart = int(x)
 62    x -= intpart
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
 92
 93
 94def nice_grams_range(x, y):
 95    assert x <= y 96    x_kg = x.to(ureg.kg)
 97    y_kg = y.to(ureg.kg)
 98    if x_kg.magnitude < 1 and y_kg.magnitude < 1:
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
107def to_nearest_tsp(x):
108    intpart = int(x)
109    x -= intpart
110    assert x <= 1111    num_dens = ((0, 1), (1, 8), (1, 4), (1, 2), (1, 1))
112    bestDiff = 2
113    for num, den in num_dens:
Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
 19    return an (integer, numerator, denominator) tuple.
 20    """
 21
 22    assert x >= 0, "_to_frac only works on positive numbers." 23 24    intpart = int(x)
 25    x -= intpart
 26