Allow passing [ConversionPoint] into create_pipeline with a type remap for ConversionPoint

This commit is contained in:
2025-08-19 02:37:01 +03:00
parent 52d82550e6
commit 9d03affd41
2 changed files with 27 additions and 8 deletions

View File

@@ -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