I'm using PyCharm for python coding. In a class, I have few fields, whose value will not be passed when instantiating the class, but will be set later. So, in __init__() method, I'm setting their values to be None. Also, to utilize PyCharm auto code completion, I'm specifying the data-type of these fields.
class SelectFrame():
index_data: pandas.DataFrame
index_filepath: Path
def __init__(self):
self.index_data = None
self.index_filepath = None
But with this, PyCharm is giving a warning Expected Type 'DataFrame', got 'None' instead. How can I remove this warning?
Note: I don't want to suppress the TypeChecker warning altogether, neither do I want to put the comment # noinspection PyTypeChecker everywhere I use such code. My question is
Is the None initialization correct? Or is there a better way to initialize and avoid the warning?