More a remark than critic: an else-block is not required here, because line the raise-statement in the if-block above terminates the function, so you can outdent the else-block and remove the line ``else:``.