def is_valid(self):
    if self.expires is not None and datetime.now() >= self.expires:
        return False
if self.remains is not None and self.remains <= 0:
    return False
Split long conditional expressions to lines