Replaced isinstance key_type check by always casting key value