basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

second type argument to `Generator` is unsafe

Open DetachHead opened this issue 3 months ago • 1 comments

Description

Code sample in basedpyright playground

from collections.abc import Generator
from typing import reveal_type


def iter() -> Generator[None, int, None]:
    reveal_type((yield)) # basedpyright: int, runtime: NoneType


for _ in iter():
    ...

DetachHead avatar Nov 06 '25 04:11 DetachHead

i think it's more like: generators in for loops are not checked correctly

KotlinIsland avatar Nov 06 '25 05:11 KotlinIsland