I want to type the inputs of a class method in Python 3. I want the argument to be a list of a custom class I created.
The definition of the method is as follows:
def add_report_data(self, report_data: list[ReportData]):
pass
ReportData is a regular class defined as follows:
class ReportData:
def __init__(self, system: str, value: int):
self.__system = system
self.__value = value
When executing my code I receive the following error:
def add_report_data(self, report_data: list[ReportData]):
TypeError: 'type' object is not subscriptable
However, changing the type of report_data to simply list is able to execute, but this is not exactly what I want to do. Any idea on what's going on? Thanks.