I've successfully used int(x or 0) for this type of error, so long as None should equate to 0 in the logic.
Note that this will also resolve to 0 in other cases where testing x returns False. e.g. empty list, set, dictionary or zero length string.
Sorry, Kindall already gave this answer.