# pyright: strict
import subprocess
def _capture_process_output(command: list[str]):
popen = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
for line in iter(popen.stdout.readline, ""):
yield line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise Exception(f"Process failed with exit code {return_code}")
Pyright is fine with that function and reports its return type as Generator[str, Any, None].
However, after reweriting it to yield from iter(... pyright complains about the return type being partially unknown and reports the return type as Generator[str, Unknown, None].
Consider the following snippet:
Pyright is fine with that function and reports its return type as
Generator[str, Any, None]
.However, after reweriting it to
yield from iter(...
pyright complains about the return type being partially unknown and reports the return type asGenerator[str, Unknown, None]
.