I have a function that looks a bit like this. I want the function to accept any subclass of io.IOBase - in other words, any file-like object.
def import_csv_
One of answers here explain how to use typing.cast. It may help.
typing.cast