How do I use type hints to annotate a function that returns an Iterable
that always yields two values: a bool
and a str
? The hint Tuple[bool, str]
is close, except that it limits the return value type to a tuple, not a generator or other type of iterable.
I’m mostly curious because I would like to annotate a function foo()
that is used to return multiple values like this:
always_a_bool, always_a_str = foo()
Usually functions like foo()
do something like return a, b
(which returns a tuple), but I would like the type hint to be flexible enough to replace the returned tuple with a generator or list or something else.