
Currently, this code implies that job.retries can be None. However, currently there is no way for that to be the case, and in the code we're basically treating None like -1. I think it would be appropriate to remove this guard and use type-checking to ensure that job.retries is always an integer.