Skip to content

Commit 8d9c97b

Browse files
committed
mypy
1 parent 056d699 commit 8d9c97b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tests/unit/experimental/pipeline/components.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ async def run(self, number1: int, number2: int = 2) -> IntResultModel:
4545

4646

4747
class ComponentMultiplyWithContext(Component):
48+
async def run(self, number1: int, number2: int) -> IntResultModel:
49+
return IntResultModel(result=number1 * number2)
50+
4851
async def run_with_context(
4952
self, context_: RunContext, number1: int, number2: int = 2
5053
) -> IntResultModel:

tests/unit/experimental/pipeline/test_component.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ async def test_component_run() -> None:
4141
result = await c.run(number1=1, number2=2)
4242
assert isinstance(result, IntResultModel)
4343
assert isinstance(
44-
result.result, ComponentMultiply.component_outputs["result"]["annotation"]
44+
result.result,
45+
# we know this is a type and not a bool or str:
46+
ComponentMultiply.component_outputs["result"]["annotation"], # type: ignore
4547
)
4648

4749

@@ -55,7 +57,9 @@ async def test_component_run_with_context_default_implementation() -> None:
5557
number1=1,
5658
number2=2,
5759
)
58-
assert result.result == 2
60+
# the type checker doesn't know about the type
61+
# because the method is not re-declared
62+
assert result.result == 2 # type: ignore
5963

6064

6165
@pytest.mark.asyncio

0 commit comments

Comments
 (0)