Is there a type annotation to specify "any collection or generator whose items are of a given type" using Python's type annotation system?
I have a function that doesn't care if it gets a list
or tuple
set
or generator
or whatever, as long as it is a collection of instances of a particular class.
The combining feature of ordered, unordered and lazy collections is that they are Iterable
. As such, an arbitrary "collection of T
s" should be annotated as an Iterable[T]
.