Typing information in collections.abc documentation
Hi, more recently when I've been using Python, I've been trying to annotate my code with type hints. Unfortunately, I'm not always 100% sure about how to properly annotate code using the typing module so I find myself frequently going back to look up the syntax. I'm aware that since PEP 585, many of the generic functions that used to reside in typing should now be replaced with the collections.abc alternatives. Unfortunately, most of the information that I find helpful about these type hints are still in the typing module, I often find myself looking up the annotation I want in collections.abc, realising its not there and then going back to the typing docs. I was wondering if it would be appropriate to have some of that information transferred across to the collections.abc module, or at least some reference to the typing documentation where applicable. For example collections.abc.Generator, if I wanted to add a type hint for this, the typing documentation gives a great overview: "A generator can be annotated by the generic type Generator[YieldType, SendType, ReturnType]". From what I can tell, this information is nowhere to be found in the collections.abc docs, there isn't even a mention that it could be annotated in that way apart from the "New in version 3.9" section near the top of the page. Thanks, Harry.
participants (1)
-
Harry Lees