Skip to content

Commit b5be7e5

Browse files
committed
Better errors for pipeline
1 parent bcfc420 commit b5be7e5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

pcs/pipeline.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import inspect
22
from collections.abc import Mapping
3-
from typing import Callable, TypeAlias, TypeVar
3+
from types import FunctionType
4+
from typing import TypeAlias, TypeVar
45

56
from pcs.component import Component
67

7-
System: TypeAlias = Callable[..., None | Mapping[str, object]]
8+
System: TypeAlias = FunctionType
89

910
T = TypeVar("T")
1011

@@ -45,11 +46,14 @@ def check_for_nulls(self, system: System) -> None:
4546
return
4647
for parameter in inspect.signature(system).parameters:
4748
assert getattr(self.component, parameter) is not None, (
48-
f"System: {system.__name__} - Parameter {parameter} was None"
49+
f"System: `{system.__name__}` - Parameter `{parameter}` was None"
4950
)
5051

5152
def set_component(self, result: None | Mapping[str, object]) -> None:
5253
if result is None:
5354
return
5455
for name, obj in result.items():
56+
assert hasattr(self.component, name), (
57+
f"Component does not have an attribute called: `{name}`"
58+
)
5559
setattr(self.component, name, obj)

0 commit comments

Comments
 (0)