返回生成器表达式的函数的正确类型注释是什么?
例如:
def foo(): return (x*x for x in range(10))
我想不通,如果这是-> Iterator[int],-> Iterable[int],-> Generator[int, None, None],或别的东西。
-> Iterator[int]
-> Iterable[int]
-> Generator[int, None, None]
如果应该有一种-最好只有一种-显而易见的方法,那么这里有什么明显的方法呢?
python yield generator type-hinting
generator ×1
python ×1
type-hinting ×1
yield ×1