Open BlackHC opened 3 months ago
Describe the bug
Partial implements both or and ror the same way:
class Partial(tp.Generic[T]): def __init__(self, f): self.f = f def __or__(self, stage) -> T: return self.f(stage) def __ror__(self, stage) -> T: return self.f(stage) def __call__(self, stage) -> T: return self.f(stage)
Both cannot be correct at the same time; ror is correct and or ought to be removed.
Minimal code to reproduce Small snippet that contains a minimal amount of code.
import pypeln async def inc(x): return x+1 assert list(range(1,11)) == await (range(10) | pypeln.task.map(inc)) assert list(range(1,11)) == await (pypeln.task.map(inc) | range(10))
The first pipe range(10) | pypeln.task.map(inc) is correct according to the API.
range(10) | pypeln.task.map(inc)
The second pipe pypeln.task.map(inc) | range(10) is definitely not valid (and should not be).
pypeln.task.map(inc) | range(10)
Expected behavior
pypeln.task.map(inc) | range(10) should lead to an error.
Deleting or indeed fixes it.
del pypeln.utils.Partial.__or__ await (pypeln.task.map(inc) | range(10))
leads to
TypeError: unsupported operand type(s) for |: 'Partial' and 'range'
Library Info Please provide os info and elegy version.
import pypeln print(pypeln.__version__)
returns 0.4.9
Describe the bug
Partial implements both or and ror the same way:
Both cannot be correct at the same time; ror is correct and or ought to be removed.
Minimal code to reproduce Small snippet that contains a minimal amount of code.
The first pipe
range(10) | pypeln.task.map(inc)
is correct according to the API.The second pipe
pypeln.task.map(inc) | range(10)
is definitely not valid (and should not be).Expected behavior
pypeln.task.map(inc) | range(10)
should lead to an error.Deleting or indeed fixes it.
leads to
Library Info Please provide os info and elegy version.
returns 0.4.9