Closed evanlouie closed 5 months ago
Hi Pyright is unfortunately not good at inferring the types of lambda functions. The problem here is not seq.map
nor the pipe method. To fix this (until pyright can infer the types better) you need to assign the lambdas to variables and give them types e.g:
mapper: Callable[[int], int] = lambda x: x * 10
predicate: Callable[[int], bool] = lambda x: x > 100
folder: Callable[[int, int], int] = lambda s, x: s + x
ys = xs.pipe(
seq.map(mapper),
seq.filter(predicate),
seq.fold(folder, 0),
)
I'll update the examples
Describe the bug
The functional
pipe
examples whereseq.map
is the first function in the pipe causes a type error.To Reproduce Steps to reproduce the behavior:
Expected behavior
pyright type checks correctly
Code or Screenshots
This causes type error:
This passes:
Additional context Add any other context about the problem here.