Answer Type . If you have the typing module installed, you can also bind this class as a subclass of something, as in the following example:
class BaseUser(): pass class Admin(BaseUser): pass class Staff(BaseUser): pass class Client(BaseUser): pass
then
from typing import Type, TypeVar U = TypeVar('U', bound=BaseUser) def new_user(user_class): """ type user_class: Type[U] """ return user_class()
and the following are use
new_user(Admin) new_user(Client) new_user(Staff)
Picharm | IDEA understands typing hints well, so it will do the trick
source share