Guido van Rossum <> added the comment:

Well, in typeshed, weakref.WeakSet and the others are generic, so you should be 
able to write

  from __future__ import annotations

  from weakref import WeakSet

  users: WeakSet[User]

Or if you need to support Python versions < 3.7, you could write

  users: 'WeakSet[User]'

Does that not solve your problem? It would be easier than adding yet another 
random class (or classes) to typing, which won't work for Python < 3.9 because is in the stdlib (and PEP 484 is no longer provisional).


Python tracker <>
Python-bugs-list mailing list

Reply via email to