There's a kwarg on the parser.add_argument called choices that sets the allowable values for a CL argument. It's usage would be something like choices = [0, 1, 2] up on line 61, and it would do this type of error checking automagically.
This will allow cleaning up range validation for certain CL arguments
Per comment from @c-to-the-fazzy :
This will allow cleaning up range validation for certain CL arguments