Allow passing [ConversionPoint] into create_pipeline with a type remap for ConversionPoint
This commit is contained in:
@@ -24,13 +24,11 @@ def test_basic():
|
||||
def int_to_a(i: int) -> A:
|
||||
return A(i)
|
||||
|
||||
type HackInt = int
|
||||
|
||||
def consumer(dep: A) -> int:
|
||||
return dep.a
|
||||
def consumer(dep: A) -> B:
|
||||
return B(float(dep.a))
|
||||
|
||||
type NewA = A
|
||||
type_remap = {'dep': NewA, 'return': Annotated[HackInt, 'fuck']}
|
||||
type_remap = {'dep': NewA, 'return': B}
|
||||
|
||||
assert len(ConversionPoint.from_fn(consumer, type_remap=type_remap)) == 1
|
||||
|
||||
@@ -43,5 +41,18 @@ def test_basic():
|
||||
fn1 = repo.get_conversion((int,), ConversionPoint.from_fn(consumer, type_remap=type_remap),
|
||||
force_commutative=True, force_async=False, allow_async=False)
|
||||
|
||||
assert fn1(42) == 42
|
||||
assert fn1(42).b == 42.0
|
||||
|
||||
def consumer1(dep: B) -> A:
|
||||
return A(int(dep.b))
|
||||
|
||||
p1 = repo.create_pipeline(
|
||||
(int,),
|
||||
[ConversionPoint.from_fn(consumer, type_remap=type_remap), consumer1, consumer],
|
||||
force_commutative=True,
|
||||
allow_sync=True,
|
||||
allow_async=False,
|
||||
force_async=False
|
||||
)
|
||||
|
||||
assert p1(123).b == 123.0
|
||||
|
||||
Reference in New Issue
Block a user