from __future__ import annotations
import operator
from typing import Callable
def safe_fold_left[T, U](lst: list[T], init: U, f: Callable[[U, T], U]) -> U:
for e in lst:
init = f(init, e)
return init
x = safe_fold_left([1, 2, 3, 4], 1, operator.mul) # this is fine...
y = safe_fold_left([1, 2, 3, 4], 1, lambda x, y: x * y) # type error here
Pyright 375, python 3.12 TY