from typing import Any, Type, TypeVar

class MyClass:
    def __init__(self, x: int) -> None:
        self.x = x

    def __repr__(self) -> str:
        return f'C(x={self.x})'

T = TypeVar('T')
def make_object(cls: Type[T], *args: Any) -> T:
    print('making object of', cls)
    obj = cls(*args)
    return obj


c = make_object(MyClass, 42) # Making object of <class '__main__.MyClass'>

print(c)        # C(x=42)
print(c.x)      # 42

reveal_type(c)  # Revealed type is 'test.MyClass'