How do I use the constructor of a python Generic typed class?
T = typing.TypeVar('T')
class MyClass(typing.Generic[T]):
def __init__(self, initialValue: typing.Iterable):
self.values: T = T(initialValue)
test = MyClass[tuple[int]]([1, 2, 3])
In this case I am expecting T(initialValue) to be equivalent to tuple(initialValue) but instead I get an error. "Exception has occurred: TypeError
'TypeVar' object is not callable"
I guess that's not too surprising since that's not what typing was built for, but is there a workaround to accomplish this?