I am giving a type to function. The function instantiates the type for me. The type implements BaseCustomObject but is one of many possible types.
def factory(object_to_create:[T], parameter:int=1) -> [T]:
constructor_parameter = calculation(parameter)
return object_to_create(constructor_parameter)
my_custom_object_instance = factory(MyCustomObject)
How do I annotate factory so that it is clear that it gives back whatever type I send it, and not just BaseCustomObject? I prefer not to use a Union type but to have the annotation/inspection/ide understand exactly which specific type I am getting back.