Python Type Inference Failed