地道な方法 地道に下の通り書くと型チェックを通りました。 def remove_none_iterator(it: Iterator[Optional[int]]) -> Iterator[int]: while True: try: elem = next(it) while elem is None: elem = next(it) yield elem except StopIteration: return def remove_none(iterable: Iterable[Optional[int]]) -> Iterable[int]: it = iter(iterable) return remove_none_iterator(it) ただしこれだと返り値が必ずイテレーターになってしまいます。しかしそもそも filter() 関数は iterable を受け取ってイテレー
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work. Try for free Learn more
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く