Python type hint for (any) class

Viewed 17355

I want to type hint the following function:

def get_obj_class(self) -> CLASS_TYPE:
  return self.o.__class__
  • CLASS_TYPE should denote classes.
  • self.o could be of any type determined at runtime.

On a similar note, if I have a function f(cls: CLASS_TYPE) which returns an instance of cls, is there a way to type hint the return value appropriately?

3 Answers
Related