rule.id = rule.id.split('#', 1)[0].strip()

?