@sourcenouveau Is this independent of using type hints? My functions returning containers usually return abstract protocol types, so f() -> Iterator[T]
for generator type things and f() -> Iterable[T]
for iterable type things (or Sequence
or MutableSequence
or whatever).
I don’t think a type checker is going to stop you from iterating over it twice, though, so I guess you still have to know the signature.
@pganssle Type hints would help in some cases, where the IDE can highlight misuses. I work in a code base where type hints are not used so sometimes I overlook them. Thanks!