Reputation: 6273
So, PEP 484 has the section "The type of class objects".
On this section, it is stated that the following should be possible:
U = TypeVar('U', bound=User)
def new_user(user_class: Type[U]) -> U:
user = user_class()
# (Here we could write the user object to a database)
return user
I'm just getting started on using the typing module. My problem is that when trying to find the Type hint, I just couldn't find it. It is nowhere in the source code or in the documentation.
The release notes indicate that the typing module implements PEP 484. There is no indication of an incomplete implementation. Is there a way to make this kind of type hint on the current version? Or is it simply impossible for now?
Thanks.
Upvotes: 1
Views: 151