I have a function argument which can accept several types for an image:
def somefunc(img: Union[np.array, Image, Path, str]):
The PIL Image in this case throws the following exception:
TypeError: Union[arg, ...]: each arg must be a type. Got <module 'PIL.Image' from ...
Which makes sense after inspecting an image object further:
print(type(Image.open('someimage.tiff')))
>>> <class 'PIL.TiffImagePlugin.TiffImageFile'>
How would I go about specifying a generalized type for a PIL image? It being from a file and it's format should be irrelevant.