-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Labels
topic: otherOther topics not coveredOther topics not covered
Description
Currently collections.abc.Generator/Coroutine/AsyncGenerator etc. have attributes that don't have to exist at runtime. I think it'd be wise to switch recommending to using the types concrete classes where possible over the abstract versions which have a smaller interface because having this weird sort of duplication where the 2 are basically the same is a wrinkle that's bitten me recently. To do this I think a few things need to happen:
- make the classes in
collections.abc.pyiProtocols that should be based on their runtime implementation (they implement custom__subclasshook__) and not the concrete types. (Make collections.abcs more consistent with runtime implementation typeshed#10816) - make the
typesclasses subscriptable at runtime. (gh-110209: Add __class_getitem__ for generator and coroutine cpython#110212) - make type checkers infer things like
def foo(): yieldastypes.GeneratorTypeand not justcollections.abc.Generator.
(as a small aside it might be nice to move the type implementations from typing to collections.abc soon)
refs: microsoft/pyright#6053
Metadata
Metadata
Assignees
Labels
topic: otherOther topics not coveredOther topics not covered