Can't you just do `isinstance(flavor, type)` here?