import dataclasses import os import subprocess import sys import time import typing @dataclasses.dataclass(frozen=True) class Effects: execv: typing.Callable[[str, list[str]], None] input: typing.Callable[[str], str] on_terminal: typing.Callable[[], bool] popen: typing.Callable[..., subprocess.Popen] run: typing.Callable[..., subprocess.CompletedProcess] sleep: typing.Callable[[float], None] def system_effects() -> Effects: return Effects( execv=os.execv, input=input, on_terminal=lambda: sys.stdin.isatty() and sys.stdout.isatty(), popen=subprocess.Popen, run=subprocess.run, sleep=time.sleep, )